diff --git a/build.gradle.kts b/build.gradle.kts index f3faa52b..99bc31af 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,6 +32,7 @@ plugins { alias(libs.plugins.shadow) alias(libs.plugins.spotless) alias(libs.plugins.nexusPublish) + alias(libs.plugins.protobuf) } val buildInfo = project.extensions.getByType() @@ -77,10 +78,13 @@ dependencies { implementation(libs.kotlinxSerializationJson) implementation(libs.jspecify) // used by jtreesitter implementation(libs.jtreesitter) + implementation(libs.protobuf) // stdlib files are included from a one-off configuration then bundled into shadow jar (see // shadowJar spec). // declare a regular dependency for testing only. testRuntimeOnly(libs.pklStdlib) + // Add pkl stdlib as runtime dependency for development/debug commands + runtimeOnly(libs.pklStdlib) testRuntimeOnly("org.junit.platform:junit-platform-launcher") testImplementation(libs.assertJ) testImplementation(libs.junitJupiter) @@ -96,6 +100,11 @@ dependencies { val configurePklCliExecutable by tasks.registering { doLast { pklCli.singleFile.setExecutable(true) } } +protobuf { + protoc { artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}" } + generateProtoTasks { all().forEach { it.builtins { create("kotlin") } } } +} + tasks.jar { manifest { attributes("Main-Class" to "org.pkl.lsp.cli.Main", "Enable-Native-Access" to "ALL-UNNAMED") diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dad91e69..8bc0ba6a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,6 +11,8 @@ ktfmt = "0.53" lsp4j = "0.23.1" nexusPublishPlugin = "2.0.0" pkl = "0.29.0" +protobuf = "4.28.3" +protobufPlugin = "0.9.4" shadowPlugin = "8.1.1" spotless = "6.25.0" treeSitterRepo = "v0.25.3" # git tag name @@ -36,10 +38,12 @@ junitEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", vers kotlinxSerializationJson = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx" } lsp4j = { group = "org.eclipse.lsp4j", name = "org.eclipse.lsp4j", version.ref = "lsp4j" } pklStdlib = { group = "org.pkl-lang", name = "pkl-stdlib", version.ref = "pkl" } +protobuf = { group = "com.google.protobuf", name = "protobuf-kotlin", version.ref = "protobuf" } [plugins] kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadowPlugin" } spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } -nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPublishPlugin" } \ No newline at end of file +nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPublishPlugin" } +protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" } \ No newline at end of file diff --git a/pkl-pantrysnapshot/basePklProject.pkl b/pkl-pantrysnapshot/basePklProject.pkl new file mode 100755 index 00000000..20fbef3a --- /dev/null +++ b/pkl-pantrysnapshot/basePklProject.pkl @@ -0,0 +1,131 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module basePklProject +//^^^^^^^^^^^^^^^^^^^^^ definition pkl . . . `basePklProject.pkl`/ + + amends "pkl:Project" + + import "pkl:reflect" + + local myModule = reflect.Module(module) +// ^^^^^^^^ definition local myModule_22 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module(). + + local packageName: String = +// ^^^^^^^^^^^ definition local packageName_24 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + findRootModule(myModule) +// ^^^^^^^^^^^^^^ reference local findRootModule_29 +// ^^^^^^^^ reference local myModule_22 + .relativePathTo(module) +// ^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#relativePathTo(). + .last +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + + local function findRootModule(mod: reflect.Module): Module = +// ^^^^^^^^^^^^^^ definition local findRootModule_29 +// ^^^ definition local mod_29 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module# + let (supermodule = mod.supermodule) +// ^^^^^^^^^^^ definition local supermodule_30 +// ^^^ reference local mod_29 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#supermodule. + if (supermodule == null || !supermodule.isAmend) mod.reflectee +// ^^^^^^^^^^^ reference local supermodule_30 +// ^^^^^^^^^^^ reference local supermodule_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#isAmend. +// ^^^ reference local mod_29 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#reflectee. + else findRootModule(supermodule) +// ^^^^^^^^^^^^^^ reference local findRootModule_29 +// ^^^^^^^^^^^ reference local supermodule_30 + + const local allTests = import*("**/tests/**.pkl").keys.filter((it) -> !it.contains("tests/fixtures/")) +// ^^^^^^^^ definition local allTests_34 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#keys. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#filter(). +// ^^ definition local it_34 +// ^^ reference local it_34 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + + package { +//^^^^^^^ definition pkl . . . `basePklProject.pkl`/package. + name = packageName +// ^^^^ definition pkl . . . `basePklProject.pkl`/name. +// ^^^^^^^^^^^ reference local packageName_24 + apiTests = tests // api tests are shared with module tests +// ^^^^^^^^ definition pkl . . . `basePklProject.pkl`/apiTests. +// ^^^^^ reference pkl . . . `basePklProject.pkl`/tests. + baseUri = "package://pkg.pkl-lang.org/pkl-pantry/\(name)" +// ^^^^^^^ definition pkl . . . `basePklProject.pkl`/baseUri. +// ^^^^ reference pkl . . . `basePklProject.pkl`/name. + packageZipUrl = "https://github.com/apple/pkl-pantry/releases/download/\(name)@\(version)/\(name)@\(version).zip" +// ^^^^^^^^^^^^^ definition pkl . . . `basePklProject.pkl`/packageZipUrl. +// ^^^^ reference pkl . . . `basePklProject.pkl`/name. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.Project`/Package#version. +// ^^^^ reference pkl . . . `basePklProject.pkl`/name. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.Project`/Package#version. + license = "Apache-2.0" +// ^^^^^^^ definition pkl . . . `basePklProject.pkl`/license. + authors { +// ^^^^^^^ definition pkl . . . `basePklProject.pkl`/authors. + "The Pkl Authors " + } + exclude { +// ^^^^^^^ definition pkl . . . `basePklProject.pkl`/exclude. + "examples/**" + "tests/**" + } + description = myModule.docComment +// ^^^^^^^^^^^ definition pkl . . . `basePklProject.pkl`/description. +// ^^^^^^^^ reference local myModule_22 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#docComment. + issueTracker = "https://github.com/apple/pkl-pantry/issues" +// ^^^^^^^^^^^^ definition pkl . . . `basePklProject.pkl`/issueTracker. + sourceCode = "https://github.com/apple/pkl-pantry/tree/\(name)@\(version)/packages/\(name)" +// ^^^^^^^^^^ definition pkl . . . `basePklProject.pkl`/sourceCode. +// ^^^^ reference pkl . . . `basePklProject.pkl`/name. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.Project`/Package#version. +// ^^^^ reference pkl . . . `basePklProject.pkl`/name. + sourceCodeUrlScheme = "https://github.com/apple/pkl-pantry/blob/\(name)@\(version)/packages/\(name)%{path}#L%{line}-%{endLine}" +// ^^^^^^^^^^^^^^^^^^^ definition pkl . . . `basePklProject.pkl`/sourceCodeUrlScheme. +// ^^^^ reference pkl . . . `basePklProject.pkl`/name. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.Project`/Package#version. +// ^^^^ reference pkl . . . `basePklProject.pkl`/name. + } + + tests { +//^^^^^ definition pkl . . . `basePklProject.pkl`/tests. + for (test in allTests) { +// ^^^^ definition local test_56 +// ^^^^^^^^ reference local allTests_34 + when (test.split("/").first == package.name) { +// ^^^^ reference local test_56 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. +// ^^^^^^^ reference pkl . . . `basePklProject.pkl`/package. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.Project`/Package#name. + test.replaceFirst(package.name, ".") +// ^^^^ reference local test_56 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^^^^ reference pkl . . . `basePklProject.pkl`/package. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.Project`/Package#name. + } + } + } + diff --git a/pkl-pantrysnapshot/com.circleci.v2/Config.pkl b/pkl-pantrysnapshot/com.circleci.v2/Config.pkl new file mode 100755 index 00000000..3b3767bf --- /dev/null +++ b/pkl-pantrysnapshot/com.circleci.v2/Config.pkl @@ -0,0 +1,1843 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Schema for CircleCI's `config.yml`. + /// + /// This module is a work in progress, if you find some unsuported feature + /// feel free to add it. + module com.circleci.v2.Config +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ + + /// Version of the `config.yml` schema to target. + /// + /// Currently, only version 2.1 is supported by this template. + version: "2.1" +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/version. +//documentation +//> Version of the `config.yml` schema to target. +//> +//> Currently, only version 2.1 is supported by this template. + + /// Designates the config.yaml for use of CircleCI’s + /// [dynamic configuration](https://circleci.com/docs/dynamic-config/) feature. + setup: Boolean? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/setup. +//documentation +//> Designates the config.yaml for use of CircleCI’s +//> [dynamic configuration](https://circleci.com/docs/dynamic-config/) feature. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// A map of user-selected names to either: orb references (strings) or orb definitions (maps). + /// + /// Orb definitions must be the orb-relevant subset of 2.1 config. + /// See the [Creating Orbs](https://circleci.com/docs/creating-orbs/) documentation for details. + orbs: Mapping? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/orbs. +//documentation +//> A map of user-selected names to either: orb references (strings) or orb definitions (maps). +//> +//> Orb definitions must be the orb-relevant subset of 2.1 config. +//> See the [Creating Orbs](https://circleci.com/docs/creating-orbs/) documentation for details. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Orb# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Executors define the execution environment in which the steps of a job will be run, + /// allowing you to reuse a single executor definition across multiple jobs. + /// + /// See [executors in the CircleCI documentation](https://circleci.com/docs/configuration-reference/#executors). + /// Also see [Using Workspaces to Share Data between Jobs](https://circleci.com/docs/workspaces/) for information on + /// how to use executors to share state between jobs. + executors: Mapping? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/executors. +//documentation +//> Executors define the execution environment in which the steps of a job will be run, +//> allowing you to reuse a single executor definition across multiple jobs. +//> +//> See [executors in the CircleCI documentation](https://circleci.com/docs/configuration-reference/#executors). +//> Also see [Using Workspaces to Share Data between Jobs](https://circleci.com/docs/workspaces/) for information on +//> how to use executors to share state between jobs. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Executor# + + /// A command defines a sequence of steps as a map to be executed in a job, enabling you to reuse + /// a single command definition across multiple jobs. + /// + /// For more information see the + /// [Reusable Config Reference Guide](https://circleci.com/docs/reusing-config/). + commands: Mapping? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/commands. +//documentation +//> A command defines a sequence of steps as a map to be executed in a job, enabling you to reuse +//> a single command definition across multiple jobs. +//> +//> For more information see the +//> [Reusable Config Reference Guide](https://circleci.com/docs/reusing-config/). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Command# + + /// A Workflow is comprised of one or more uniquely named jobs. + /// + /// Jobs are specified in the jobs map, see + /// [Sample config.yml](https://circleci.com/docs/sample-config/) for two examples of a job map. + /// The name of the job is the key in the map, and the value is a map describing the job. + jobs: Mapping? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/jobs. +//documentation +//> A Workflow is comprised of one or more uniquely named jobs. +//> +//> Jobs are specified in the jobs map, see +//> [Sample config.yml](https://circleci.com/docs/sample-config/) for two examples of a job map. +//> The name of the job is the key in the map, and the value is a map describing the job. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job# + + /// Used for orchestrating all jobs. + /// + /// Each workflow consists of the workflow name as a key and a map as a value. + /// A name should be unique within the current config.yml. + /// The top-level keys for the Workflows configuration are version and jobs. + /// For more information, see the + /// [Using Workflows to Orchestrate Jobs](https://circleci.com/docs/workflows/) page. + workflows: Mapping? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/workflows. +//documentation +//> Used for orchestrating all jobs. +//> +//> Each workflow consists of the workflow name as a key and a map as a value. +//> A name should be unique within the current config.yml. +//> The top-level keys for the Workflows configuration are version and jobs. +//> For more information, see the +//> [Using Workflows to Orchestrate Jobs](https://circleci.com/docs/workflows/) page. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Workflow# + + /// Pipeline parameters declared for use in the configuration. + /// + /// See [Pipeline Values and Parameters](https://circleci.com/docs/pipeline-variables/#pipeline-parameters-in-configuration) + /// for usage details. + parameters: Mapping? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/parameters. +//documentation +//> Pipeline parameters declared for use in the configuration. +//> +//> See [Pipeline Values and Parameters](https://circleci.com/docs/pipeline-variables/#pipeline-parameters-in-configuration) +//> for usage details. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Parameter# + + class Orb { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Orb# + /// A map of user-selected names to either: orb references (strings) or orb definitions (maps). + /// + /// Orb definitions must be the orb-relevant subset of 2.1 config. + /// See the [Creating Orbs](https://circleci.com/docs/creating-orbs/) documentation for details. + orbs: Mapping? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Orb#orbs. +// documentation +// > A map of user-selected names to either: orb references (strings) or orb definitions (maps). +// > +// > Orb definitions must be the orb-relevant subset of 2.1 config. +// > See the [Creating Orbs](https://circleci.com/docs/creating-orbs/) documentation for details. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Orb# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A command defines a sequence of steps as a map to be executed in a job, enabling you to reuse + /// a single command definition across multiple jobs. + /// + /// For more information see the + /// [Reusable Config Reference Guide](https://circleci.com/docs/reusing-config/). + commands: Mapping? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Orb#commands. +// documentation +// > A command defines a sequence of steps as a map to be executed in a job, enabling you to reuse +// > a single command definition across multiple jobs. +// > +// > For more information see the +// > [Reusable Config Reference Guide](https://circleci.com/docs/reusing-config/). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Command# + + /// A Workflow is comprised of one or more uniquely named jobs. + /// + /// Jobs are specified in the jobs map, see + /// [Sample config.yml](https://circleci.com/docs/sample-config/) for two examples of a job map. + /// The name of the job is the key in the map, and the value is a map describing the job. + jobs: Mapping? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Orb#jobs. +// documentation +// > A Workflow is comprised of one or more uniquely named jobs. +// > +// > Jobs are specified in the jobs map, see +// > [Sample config.yml](https://circleci.com/docs/sample-config/) for two examples of a job map. +// > The name of the job is the key in the map, and the value is a map describing the job. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job# + } + + class Executor { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Executor# + /// Which resource class to use which further determines the amount of CPU and RAM allocated to each container in a + /// job. + resource_class: ResourceClass? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Executor#resource_class. +// documentation +// > Which resource class to use which further determines the amount of CPU and RAM allocated to each container in a +// > job. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ResourceClass# + + /// Shell to use for execution command in all steps. + /// Can be overridden by shell in each step (default: See [Default Shell Options](https://circleci.com/docs/configuration-reference/#default-shell-options)) + shell: String? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Executor#shell. +// documentation +// > Shell to use for execution command in all steps. +// > Can be overridden by shell in each step (default: See [Default Shell Options](https://circleci.com/docs/configuration-reference/#default-shell-options)) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// In which directory to run the steps. Will be interpreted as an absolute path. + working_directory: String? +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Executor#working_directory. +// documentation +// > In which directory to run the steps. Will be interpreted as an absolute path. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A map of environment variable names and values. + environment: Mapping? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Executor#environment. +// documentation +// > A map of environment variable names and values. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Options for [docker executor](https://circleci.com/docs/configuration-reference/#docker) + docker: Listing(!isEmpty)?(onlyOneSet(List(this, macos, machine))) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Executor#docker. +// documentation +// > Options for [docker executor](https://circleci.com/docs/configuration-reference/#docker) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/DockerImage# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. +// ^^^^^^^^^^ reference local onlyOneSet_708 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Executor#macos. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Executor#machine. + + /// Options for [macOS executor](https://circleci.com/docs/configuration-reference/#macos) + macos: MacOSExecutor? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Executor#macos. +// documentation +// > Options for [macOS executor](https://circleci.com/docs/configuration-reference/#macos) +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/MacOSExecutor# + + /// Options for [machine executor](https://circleci.com/docs/configuration-reference/#machine) + machine: Machine? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Executor#machine. +// documentation +// > Options for [machine executor](https://circleci.com/docs/configuration-reference/#machine) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Machine# + } + + class Job { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job# + /// Shell to use for execution command in all steps. + /// + /// Can be overridden by shell in each step (default: See Default Shell Options) + shell: String? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#shell. +// documentation +// > Shell to use for execution command in all steps. +// > +// > Can be overridden by shell in each step (default: See Default Shell Options) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A list of [steps](https://circleci.com/docs/configuration-reference/#steps) to be performed + steps: Listing(!isEmpty) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#steps. +// documentation +// > A list of [steps](https://circleci.com/docs/configuration-reference/#steps) to be performed +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Step# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + + /// A pre-defined executor from the defined executors or orbs in which to execute this job. + /// + /// Can be used to share data between jobs. + /// See [Using Workspaces to Share Data between Jobs](https://circleci.com/docs/workspaces/) for information on how to + /// use executors to share state between jobs. + executor: String? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#executor. +// documentation +// > A pre-defined executor from the defined executors or orbs in which to execute this job. +// > +// > Can be used to share data between jobs. +// > See [Using Workspaces to Share Data between Jobs](https://circleci.com/docs/workspaces/) for information on how to +// > use executors to share state between jobs. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// In which directory to run the steps. + /// + /// Will be interpreted as an absolute path. + /// + /// Default: `~/project` (where project is a literal string, not the name of your specific project). + /// + /// Processes run during the job can use the `$CIRCLE_WORKING_DIRECTORY` environment variable to + /// refer to this directory. + /// + /// Note: Paths written in your YAML configuration file will not be expanded; if your + /// store_test_results.path is $CIRCLE_WORKING_DIRECTORY/tests, then CircleCI will attempt to + /// store the test subdirectory of the directory literally named $CIRCLE_WORKING_DIRECTORY, + /// dollar sign $ and all. working_directory will be created automatically if it doesn’t exist. + working_directory: String? +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#working_directory. +// documentation +// > In which directory to run the steps. +// > +// > Will be interpreted as an absolute path. +// > +// > Default: `~/project` (where project is a literal string, not the name of your specific project). +// > +// > Processes run during the job can use the `$CIRCLE_WORKING_DIRECTORY` environment variable to +// > refer to this directory. +// > +// > Note: Paths written in your YAML configuration file will not be expanded; if your +// > store_test_results.path is $CIRCLE_WORKING_DIRECTORY/tests, then CircleCI will attempt to +// > store the test subdirectory of the directory literally named $CIRCLE_WORKING_DIRECTORY, +// > dollar sign $ and all. working_directory will be created automatically if it doesn’t exist. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Number of parallel instances of this job to run (default: 1) + parallelism: Int? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#parallelism. +// documentation +// > Number of parallel instances of this job to run (default: 1) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Job-level parameters can be used when calling a job in a workflow + parameters: Mapping? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#parameters. +// documentation +// > Job-level parameters can be used when calling a job in a workflow +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Parameter# + + /// A map of environment variable names and values. + environment: Mapping? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#environment. +// documentation +// > A map of environment variable names and values. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The [resource_class](https://circleci.com/docs/resource-class-overview/) feature allows you to configure CPU and RAM resources for each job. + /// + /// Resource classes are available for each execution environment, as described in the tables below. + /// + /// We implement soft concurrency limits for each resource class to ensure our system remains + /// stable for all customers. + /// If you are on a Performance or custom plan and experience queuing for certain resource + /// classes, it is possible you are hitting these limits. + /// Contact [CircleCI support](https://support.circleci.com/hc/en-us/requests/new) to request a + /// raise on these limits for your account. + /// + /// If you do not specify a resource class, CircleCI will use a default value that is subject + /// to change. + /// It is best practice to specify a resource class as opposed to relying on a default. + resource_class: ResourceClass? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#resource_class. +// documentation +// > The [resource_class](https://circleci.com/docs/resource-class-overview/) feature allows you to configure CPU and RAM resources for each job. +// > +// > Resource classes are available for each execution environment, as described in the tables below. +// > +// > We implement soft concurrency limits for each resource class to ensure our system remains +// > stable for all customers. +// > If you are on a Performance or custom plan and experience queuing for certain resource +// > classes, it is possible you are hitting these limits. +// > Contact [CircleCI support](https://support.circleci.com/hc/en-us/requests/new) to request a +// > raise on these limits for your account. +// > +// > If you do not specify a resource class, CircleCI will use a default value that is subject +// > to change. +// > It is best practice to specify a resource class as opposed to relying on a default. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ResourceClass# + + /// Options for [docker executor](https://circleci.com/docs/configuration-reference/#docker) + docker: Listing(!isEmpty)?(onlyOneSet(List(this, executor, macos, machine))) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#docker. +// documentation +// > Options for [docker executor](https://circleci.com/docs/configuration-reference/#docker) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/DockerImage# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. +// ^^^^^^^^^^ reference local onlyOneSet_708 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#executor. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#macos. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#machine. + + /// CircleCI supports running jobs on macOS, to allow you to build, test, and deploy apps for + /// macOS, iOS, tvOS and watchOS. + /// + /// To run a job in a macOS virtual machine, add the macos key to the top-level configuration + /// for your job and specify the version of Xcode you would like to use. + macos: MacOSExecutor? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#macos. +// documentation +// > CircleCI supports running jobs on macOS, to allow you to build, test, and deploy apps for +// > macOS, iOS, tvOS and watchOS. +// > +// > To run a job in a macOS virtual machine, add the macos key to the top-level configuration +// > for your job and specify the version of Xcode you would like to use. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/MacOSExecutor# + + /// Options for [machine executor](https://circleci.com/docs/configuration-reference/#machine) + machine: Machine? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Job#machine. +// documentation +// > Options for [machine executor](https://circleci.com/docs/configuration-reference/#machine) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Machine# + } + + typealias ResourceClass = +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ResourceClass# + "small" + |"medium" + |"medium+" + |"large" + |"xlarge" + |"2xlarge" + |"2xlarge+" + |"arm.medium" + |"arm.large" + |"arm.xlarge" + |"arm.2xlarge" + |"macos.m1.medium.gen1" + |"macos.m1.large.gen1" + |"m2pro.medium" + |"m2pro.large" + |"windows.medium" + |"windows.large" + |"windows.xlarge" + |"windows.2xlarge" + |"gpu.nvidia.small" + |"gpu.nvidia.small.gen2" + |"gpu.nvidia.small.multi" + |"gpu.nvidia.medium.multi" + |"gpu.nvidia.medium" + |"gpu.nvidia.large" + |"windows.gpu.nvidia.medium" + + + class MacOSExecutor { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/MacOSExecutor# + /// The version of Xcode that is installed on the virtual machine, see the + /// [Supported Xcode Versions section of the Testing iOS document](https://circleci.com/docs/using-macos/#supported-xcode-versions) + /// for the complete list. + xcode: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/MacOSExecutor#xcode. +// documentation +// > The version of Xcode that is installed on the virtual machine, see the +// > [Supported Xcode Versions section of the Testing iOS document](https://circleci.com/docs/using-macos/#supported-xcode-versions) +// > for the complete list. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + class Machine { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Machine# + /// The virtual machine image to use. + /// + /// View [available images](https://circleci.com/developer/images?imageType=machine). + /// + /// Note: This key is *not* supported for Linux VMs on installations of CircleCI server. + /// For information about customizing `machine` executor images on CircleCI installed on your + /// servers, see our [VM Service documentation](https://circleci.com/docs/server/v4.1/operator/manage-virtual-machines-with-vm-service/) + image: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Machine#image. +// documentation +// > The virtual machine image to use. +// > +// > View [available images](https://circleci.com/developer/images?imageType=machine). +// > +// > Note: This key is *not* supported for Linux VMs on installations of CircleCI server. +// > For information about customizing `machine` executor images on CircleCI installed on your +// > servers, see our [VM Service documentation](https://circleci.com/docs/server/v4.1/operator/manage-virtual-machines-with-vm-service/) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Set this to `true` to enable [Docker Layer Caching](https://circleci.com/docs/docker-layer-caching/). + docker_layer_caching: Boolean? +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Machine#docker_layer_caching. +// documentation +// > Set this to `true` to enable [Docker Layer Caching](https://circleci.com/docs/docker-layer-caching/). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + class DockerImage { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/DockerImage# + /// The name of a custom docker image to use. + /// + /// The first `image` listed under a job defines the job’s own primary container image where all + /// steps will run. + image: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/DockerImage#image. +// documentation +// > The name of a custom docker image to use. +// > +// > The first `image` listed under a job defines the job’s own primary container image where all +// > steps will run. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// `name` defines the the hostname for the container (the default is `localhost`), which is used + /// for reaching secondary (service) containers. + /// + /// By default, all services are exposed directly on `localhost`. + /// This field is useful if you would rather have a different hostname instead of `localhost`, + /// for example, if you are starting multiple versions of the same service. + name: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/DockerImage#name. +// documentation +// > `name` defines the the hostname for the container (the default is `localhost`), which is used +// > for reaching secondary (service) containers. +// > +// > By default, all services are exposed directly on `localhost`. +// > This field is useful if you would rather have a different hostname instead of `localhost`, +// > for example, if you are starting multiple versions of the same service. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The command used as executable when launching the container. + /// + /// [entrypoint] overrides the image’s `ENTRYPOINT` + entrypoint: (*Listing|String)? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/DockerImage#entrypoint. +// documentation +// > The command used as executable when launching the container. +// > +// > [`entrypoint`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.circleci.v2/Config.pkl#L259,C3) overrides the image’s `ENTRYPOINT` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The command used as pid 1 (or args for entrypoint) when launching the container. + /// + /// [command] overrides the image’s `COMMAND`. + /// It will be used as arguments to the image `ENTRYPOINT` if it has one, or as the executable + /// if the image has no `ENTRYPOINT`. + command: (*Listing|String)? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/DockerImage#command. +// documentation +// > The command used as pid 1 (or args for entrypoint) when launching the container. +// > +// > [`command`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.circleci.v2/Config.pkl#L266,C3) overrides the image’s `COMMAND`. +// > It will be used as arguments to the image `ENTRYPOINT` if it has one, or as the executable +// > if the image has no `ENTRYPOINT`. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Which user to run commands as within the Docker container + user: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/DockerImage#user. +// documentation +// > Which user to run commands as within the Docker container +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// environment variable names and values. + /// + /// The [environment] settings apply to the entrypoint/command run by the docker container, not + /// the job steps + environment: Mapping? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/DockerImage#environment. +// documentation +// > environment variable names and values. +// > +// > The [`environment`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.circleci.v2/Config.pkl#L275,C3) settings apply to the entrypoint/command run by the docker container, not +// > the job steps +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Authentication for registries using standard docker login credentials + auth: Mapping? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/DockerImage#auth. +// documentation +// > Authentication for registries using standard docker login credentials +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Authentication for AWS Elastic Container Registry (ECR) + aws_auth: Mapping? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/DockerImage#aws_auth. +// documentation +// > Authentication for AWS Elastic Container Registry (ECR) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + class ScheduleTrigger { +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTrigger# + /// The cron key is defined using POSIX crontab syntax + @SourceCode { language = "cronexp" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTrigger#language. + cron: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTrigger#cron. +// documentation +// > The cron key is defined using POSIX crontab syntax +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Trigger Filters can have the key branches. + filters: ScheduleTriggerFilter +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTrigger#filters. +// documentation +// > Trigger Filters can have the key branches. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTriggerFilter# + } + + class ScheduleTriggerFilter { +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTriggerFilter# + /// The `branches` key controls whether the _current_ branch should have a schedule trigger + /// created for it, where _current_ branch is the branch containing the `config.yml` file with + /// the trigger stanza. + /// That is, a push on the `main` branch will only schedule a + /// [workflow](https://circleci.com/docs/workflows/#using-contexts-and-filtering-in-your-workflows) + /// for the `main` branch. + /// + /// Branches can have the keys only and ignore which each map to a single string naming a branch. + /// You may also use regular expressions to match against branches by enclosing them with `/`’s, + /// or map to a list of such strings. Regular expressions must match the **entire** string. + /// + /// * Any branches that match only will run the job. + /// * Any branches that match ignore will not run the job. + /// * If neither only nor ignore are specified then all branches will run the job. + /// If both only and ignore are specified, the only is used and ignore will have no effect. + branches: ScheduleTriggerFilterBranches +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTriggerFilter#branches. +// documentation +// > The `branches` key controls whether the _current_ branch should have a schedule trigger +// > created for it, where _current_ branch is the branch containing the `config.yml` file with +// > the trigger stanza. +// > That is, a push on the `main` branch will only schedule a +// > [workflow](https://circleci.com/docs/workflows/#using-contexts-and-filtering-in-your-workflows) +// > for the `main` branch. +// > +// > Branches can have the keys only and ignore which each map to a single string naming a branch. +// > You may also use regular expressions to match against branches by enclosing them with `/`’s, +// > or map to a list of such strings. Regular expressions must match the **entire** string. +// > +// > * Any branches that match only will run the job. +// > * Any branches that match ignore will not run the job. +// > * If neither only nor ignore are specified then all branches will run the job. +// > If both only and ignore are specified, the only is used and ignore will have no effect. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTriggerFilterBranches# + } + + class ScheduleTriggerFilterBranches { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTriggerFilterBranches# + /// Either a single branch specifier, or a list of branch specifiers + only: *Listing|String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTriggerFilterBranches#only. +// documentation +// > Either a single branch specifier, or a list of branch specifiers +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Either a single branch specifier, or a list of branch specifiers + ignore: (*Listing|String)? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTriggerFilterBranches#ignore. +// documentation +// > Either a single branch specifier, or a list of branch specifiers +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + class Workflow { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Workflow# + /// A job can have the keys `requires`, `name`, `context`, `type`, and `filters`. + jobs: Listing<*Mapping(length == 1)|String>(!isEmpty) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Workflow#jobs. +// documentation +// > A job can have the keys `requires`, `name`, `context`, `type`, and `filters`. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WorkflowJob# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#length. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + + /// Specifies which triggers will cause this workflow to be executed. + /// + /// Default behavior is to trigger the workflow when pushing to a branch + triggers: Listing? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Workflow#triggers. +// documentation +// > Specifies which triggers will cause this workflow to be executed. +// > +// > Default behavior is to trigger the workflow when pushing to a branch +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/ScheduleTrigger# + + `when`: (*LogicStatement|Boolean|String)? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Workflow#when. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + `unless`: (*LogicStatement|Boolean|String)? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Workflow#unless. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + class WorkflowJob { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WorkflowJob# + /// The name key can be used to invoke reusable jobs across any number of workflows. + /// + /// Using the name key ensures numbers are not appended to your job name (i.e. sayhello-1, + /// sayhello-2, etc.). + /// The name you assign to the name key needs to be unique, otherwise the numbers will still be + /// appended to the job name. + name: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WorkflowJob#name. +// documentation +// > The name key can be used to invoke reusable jobs across any number of workflows. +// > +// > Using the name key ensures numbers are not appended to your job name (i.e. sayhello-1, +// > sayhello-2, etc.). +// > The name you assign to the name key needs to be unique, otherwise the numbers will still be +// > appended to the job name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A list of jobs that must succeed for the job to start. + /// + /// Note: When jobs in the current workflow that are listed as dependencies are not executed + /// (due to a filter function for example), their requirement as a dependency for other jobs will + /// be ignored by the requires option. + /// However, if all dependencies of a job are filtered, then that job will not be executed either. + requires: Listing? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WorkflowJob#requires. +// documentation +// > A list of jobs that must succeed for the job to start. +// > +// > Note: When jobs in the current workflow that are listed as dependencies are not executed +// > (due to a filter function for example), their requirement as a dependency for other jobs will +// > be ignored by the requires option. +// > However, if all dependencies of a job are filtered, then that job will not be executed either. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The name of the context(s). + /// + /// Jobs may be configured to use global environment variables set for an organization, see the + /// [Contexts](https://circleci.com/docs/contexts/) document for adding a context in the + /// application settings. + /// + /// The initial default name is org-global. + /// Each context name must be unique. + /// If using CircleCI Server, only a single Context per workflow is supported. + /// Note: A maximum of 100 unique contexts across all workflows is allowed + context: (*Listing|String)? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WorkflowJob#context. +// documentation +// > The name of the context(s). +// > +// > Jobs may be configured to use global environment variables set for an organization, see the +// > [Contexts](https://circleci.com/docs/contexts/) document for adding a context in the +// > application settings. +// > +// > The initial default name is org-global. +// > Each context name must be unique. +// > If using CircleCI Server, only a single Context per workflow is supported. +// > Note: A maximum of 100 unique contexts across all workflows is allowed +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A job may have a type of `approval` indicating it must be manually approved before downstream + /// jobs may proceed. + /// + /// For more information see the Using Workflows to Orchestrate Jobs page. + type: "approval"? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WorkflowJob#type. +// documentation +// > A job may have a type of `approval` indicating it must be manually approved before downstream +// > jobs may proceed. +// > +// > For more information see the Using Workflows to Orchestrate Jobs page. + + /// Run a parameterized job multiple times with different arguments. + /// + /// For more information see the how-to guide on [Using Matrix Jobs](https://circleci.com/docs/using-matrix-jobs/). + /// + /// In order to use the matrix stanza, you must use parameterized jobs. + matrix: JobMatrix? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WorkflowJob#matrix. +// documentation +// > Run a parameterized job multiple times with different arguments. +// > +// > For more information see the how-to guide on [Using Matrix Jobs](https://circleci.com/docs/using-matrix-jobs/). +// > +// > In order to use the matrix stanza, you must use parameterized jobs. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/JobMatrix# + + /// Job Filters can have the key branches or tags + filters: JobFilters? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WorkflowJob#filters. +// documentation +// > Job Filters can have the key branches or tags +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/JobFilters# + + /// Supplemental job-level parameters to be specified when + /// [calling a `job` in `workflow`](https://circleci.com/docs/configuration-reference/#jobs-in-workflow). + /// + /// There are several reserved parameter names that cannot be used from CircleCI users. + hidden parameters: Mapping< +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WorkflowJob#parameters. +// documentation +// > Supplemental job-level parameters to be specified when +// > [calling a `job` in `workflow`](https://circleci.com/docs/configuration-reference/#jobs-in-workflow). +// > +// > There are several reserved parameter names that cannot be used from CircleCI users. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + String(!(this is "name"|"context"|"filters"|"matrix"|"requires"|"type")), +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + *Listing|String|Number|Boolean +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Step# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + >? + } + + class JobFilters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/JobFilters# + /// Branches can have the keys only and ignore which either map to a single string naming a branch. + /// You may also use regular expressions to match against branches by enclosing them with slashes, + /// or map to a list of such strings. + /// Regular expressions must match the *entire* string. + /// + /// Any branches that match `only` will run the job. + /// Any branches that match `ignore` will not run the job. + /// If neither `only` nor `ignore` are specified then all branches will run the job. + /// If both `only` and `ignore` are specified the `only` is considered before `ignore`. + branches: FilterSpec? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/JobFilters#branches. +// documentation +// > Branches can have the keys only and ignore which either map to a single string naming a branch. +// > You may also use regular expressions to match against branches by enclosing them with slashes, +// > or map to a list of such strings. +// > Regular expressions must match the *entire* string. +// > +// > Any branches that match `only` will run the job. +// > Any branches that match `ignore` will not run the job. +// > If neither `only` nor `ignore` are specified then all branches will run the job. +// > If both `only` and `ignore` are specified the `only` is considered before `ignore`. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/FilterSpec# + + /// CircleCI does not run workflows for tags unless you explicitly specify tag filters. + /// Additionally, if a job requires any other jobs (directly or indirectly), you must specify tag + /// filters for those jobs. + /// + /// Tags can have the keys only and ignore. + /// You may also use regular expressions to match against tags by enclosing them with slashes, + /// or map to a list of such strings. + /// Regular expressions must match the entire string. + /// Both lightweight and annotated tags are supported. + /// + /// Any tags that match only will run the job. + /// Any tags that match ignore will not run the job. + /// If neither only nor ignore are specified then the job is skipped for all tags. + /// If both only and ignore are specified the only is considered before ignore. + tags: FilterSpec? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/JobFilters#tags. +// documentation +// > CircleCI does not run workflows for tags unless you explicitly specify tag filters. +// > Additionally, if a job requires any other jobs (directly or indirectly), you must specify tag +// > filters for those jobs. +// > +// > Tags can have the keys only and ignore. +// > You may also use regular expressions to match against tags by enclosing them with slashes, +// > or map to a list of such strings. +// > Regular expressions must match the entire string. +// > Both lightweight and annotated tags are supported. +// > +// > Any tags that match only will run the job. +// > Any tags that match ignore will not run the job. +// > If neither only nor ignore are specified then the job is skipped for all tags. +// > If both only and ignore are specified the only is considered before ignore. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/FilterSpec# + } + + class FilterSpec { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/FilterSpec# + /// Either a single branch specifier, or a list of branch specifiers + only: (String|Listing)?(this != null || ignore != null) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/FilterSpec#only. +// documentation +// > Either a single branch specifier, or a list of branch specifiers +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/FilterSpec#ignore. + + /// Either a single branch specifier, or a list of branch specifiers + ignore: (String|Listing)? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/FilterSpec#ignore. +// documentation +// > Either a single branch specifier, or a list of branch specifiers +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + class JobMatrix { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/JobMatrix# + /// A map of parameter names to every value the job should be called with + parameters: Mapping> +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/JobMatrix#parameters. +// documentation +// > A map of parameter names to every value the job should be called with +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Argument maps that should be excluded from the matrix + exclude: Listing>? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/JobMatrix#exclude. +// documentation +// > Argument maps that should be excluded from the matrix +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// An alias for the matrix, usable from another job’s requires stanza. + /// + /// Defaults to the name of the job being executed + alias: String? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/JobMatrix#alias. +// documentation +// > An alias for the matrix, usable from another job’s requires stanza. +// > +// > Defaults to the name of the job being executed +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + typealias Step = AbstractStep|SimpleStepName|OrbStep +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Step# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SimpleStepName# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/OrbStep# + + typealias SimpleStepName = "checkout"|"setup_remote_docker"|"add_ssh_keyes"|String +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SimpleStepName# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + abstract class AbstractStep { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# + fixed hidden __name__: String +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep#__name__. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + typealias OrbStep = Dynamic(hasProperty("__name__")) +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/OrbStep# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#hasProperty(). + + function OrbStep(name: String): OrbStep = new { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/OrbStep(). +// ^^^^ definition local name_449 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/OrbStep# + __name__ = name +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/__name__. +// ^^^^ reference local name_449 + } + + function run(_command: String): RunStep = new { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/run(). +// ^^^^^^^^ definition local _command_453 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep# + command = _command +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/command. +// ^^^^^^^^ reference local _command_453 + } + + /// Used for invoking all command-line programs. + /// + /// Run commands are executed using non-login shells by default, so you must explicitly source any + /// dotfiles as part of the command. + class RunStep extends AbstractStep { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep# +// documentation +// > Used for invoking all command-line programs. +// > +// > Run commands are executed using non-login shells by default, so you must explicitly source any +// > dotfiles as part of the command. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# + fixed hidden __name__ = "run" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep#__name__. + + /// Command to run via the shell + command: String(!isEmpty) +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep#command. +// documentation +// > Command to run via the shell +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. + + /// Title of the step to be shown in the CircleCI UI (default: full [command]) + name: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep#name. +// documentation +// > Title of the step to be shown in the CircleCI UI (default: full [`command`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.circleci.v2/Config.pkl#L465,C3)) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Shell to use for execution command (default: See [Default Shell Options](https://circleci.com/docs/configuration-reference/#default-shell-options)) + shell: String? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep#shell. +// documentation +// > Shell to use for execution command (default: See [Default Shell Options](https://circleci.com/docs/configuration-reference/#default-shell-options)) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Additional environmental variables, locally scoped to command + environment: Mapping? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep#environment. +// documentation +// > Additional environmental variables, locally scoped to command +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Whether or not this step should run in the background (default: [false]) + background: Boolean? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep#background. +// documentation +// > Whether or not this step should run in the background (default: `false`) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// In which directory to run this step. + /// + /// Will be interpreted relative to the working_directory + /// of the job. (default: `.`) + working_directory: String? +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep#working_directory. +// documentation +// > In which directory to run this step. +// > +// > Will be interpreted relative to the working_directory +// > of the job. (default: `.`) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Elapsed time the command can run without output. + /// + /// The default is 10 minutes and the maximum is governed by the maximum time a job is allowed to run. + no_output_timeout: Duration? +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep#no_output_timeout. +// documentation +// > Elapsed time the command can run without output. +// > +// > The default is 10 minutes and the maximum is governed by the maximum time a job is allowed to run. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Specify when to enable or disable the step. + /// + /// Takes the following values: `always`, `on_success`, `on_fail` (default: on_success) + `when`: ("always"|"on_success"|"on_fail")? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep#when. +// documentation +// > Specify when to enable or disable the step. +// > +// > Takes the following values: `always`, `on_success`, `on_fail` (default: on_success) + } + + /// Generates and stores a cache of a file or directory of files such as dependencies or source + /// code in our object storage. + /// + /// Later jobs can [restore this cache](https://circleci.com/docs/configuration-reference/#restore_cache). + /// Learn more on the [Caching Dependencies](https://circleci.com/docs/caching/) page. + /// + /// Cache retention can be customized on the [CircleCI web app](https://app.circleci.com/) by + /// navigating to Plan > Usage Controls. + class SaveCacheStep extends AbstractStep { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SaveCacheStep# +// documentation +// > Generates and stores a cache of a file or directory of files such as dependencies or source +// > code in our object storage. +// > +// > Later jobs can [restore this cache](https://circleci.com/docs/configuration-reference/#restore_cache). +// > Learn more on the [Caching Dependencies](https://circleci.com/docs/caching/) page. +// > +// > Cache retention can be customized on the [CircleCI web app](https://app.circleci.com/) by +// > navigating to Plan > Usage Controls. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# + fixed hidden __name__ = "save_cache" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SaveCacheStep#__name__. + + /// List of directories which should be added to the cache + paths: Listing +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SaveCacheStep#paths. +// documentation +// > List of directories which should be added to the cache +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Unique identifier for this cache + key: String +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SaveCacheStep#key. +// documentation +// > Unique identifier for this cache +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Title of the step to be shown in the CircleCI UI (default: “Saving Cache”) + name: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SaveCacheStep#name. +// documentation +// > Title of the step to be shown in the CircleCI UI (default: “Saving Cache”) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// [Specify when to enable or disable the step](https://circleci.com/docs/configuration-reference/#the-when-attribute). + /// + /// Takes the following values: always, on_success, on_fail (default: on_success) + `when`: ("always"|"on_success"|"on_fail")? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SaveCacheStep#when. +// documentation +// > [Specify when to enable or disable the step](https://circleci.com/docs/configuration-reference/#the-when-attribute). +// > +// > Takes the following values: always, on_success, on_fail (default: on_success) + } + + /// Restores a previously saved cache based on a key. + /// + /// Cache needs to have been saved first for this key using the [save_cache] step. + /// + /// Learn more in [the caching documentation](https://circleci.com/docs/caching/). + class RestoreCacheStep extends AbstractStep { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RestoreCacheStep# +// documentation +// > Restores a previously saved cache based on a key. +// > +// > Cache needs to have been saved first for this key using the `save_cache` step. +// > +// > Learn more in [the caching documentation](https://circleci.com/docs/caching/). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# + fixed hidden __name__ = "restore_cache" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RestoreCacheStep#__name__. + + /// Single cache key to restore + key: String?(this != null || keys != null) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RestoreCacheStep#key. +// documentation +// > Single cache key to restore +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RestoreCacheStep#keys. + + /// List of cache keys to lookup for a cache to restore. + /// + /// Only first existing key will be restored. + keys: Listing? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RestoreCacheStep#keys. +// documentation +// > List of cache keys to lookup for a cache to restore. +// > +// > Only first existing key will be restored. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Title of the step to be shown in the CircleCI UI (default: “Restoring Cache”) + name: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RestoreCacheStep#name. +// documentation +// > Title of the step to be shown in the CircleCI UI (default: “Restoring Cache”) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// Allows Docker commands to be run locally. + /// + /// See [Running Docker Commands](https://circleci.com/docs/building-docker-images/) for details. + class SetupRemoteDockerStep extends AbstractStep { +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SetupRemoteDockerStep# +// documentation +// > Allows Docker commands to be run locally. +// > +// > See [Running Docker Commands](https://circleci.com/docs/building-docker-images/) for details. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# + fixed hidden __name__ = "setup_remote_docker" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SetupRemoteDockerStep#__name__. + + /// Version string of Docker you would like to use (default: 24.0.9). + /// + /// View the list of supported docker versions + /// [here](https://circleci.com/docs/building-docker-images/#docker-version). + version: String? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SetupRemoteDockerStep#version. +// documentation +// > Version string of Docker you would like to use (default: 24.0.9). +// > +// > View the list of supported docker versions +// > [here](https://circleci.com/docs/building-docker-images/#docker-version). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Set this to true to enable [Docker Layer Caching](https://circleci.com/docs/docker-layer-caching/) + /// in the Remote Docker Environment (default: false) + docker_layer_caching: Boolean? +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SetupRemoteDockerStep#docker_layer_caching. +// documentation +// > Set this to true to enable [Docker Layer Caching](https://circleci.com/docs/docker-layer-caching/) +// > in the Remote Docker Environment (default: false) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + /// Special step used to persist a temporary file to be used by another job in the workflow. + /// For more information on using workspaces, see the + /// [Using Workspaces to Share Data Between Jobs](https://circleci.com/docs/workspaces/) page. + /// + /// `persist_to_workspace` adopts the storage settings from the storage customization controls on + /// the CircleCI web app. + /// If no custom setting is provided, `persist_to_workspace` defaults to 15 days. + /// + /// Workspace storage retention can be customized on the CircleCI web app by navigating to Plan > Usage Controls. + class PersistToWorkspaceStep extends AbstractStep { +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PersistToWorkspaceStep# +// documentation +// > Special step used to persist a temporary file to be used by another job in the workflow. +// > For more information on using workspaces, see the +// > [Using Workspaces to Share Data Between Jobs](https://circleci.com/docs/workspaces/) page. +// > +// > `persist_to_workspace` adopts the storage settings from the storage customization controls on +// > the CircleCI web app. +// > If no custom setting is provided, `persist_to_workspace` defaults to 15 days. +// > +// > Workspace storage retention can be customized on the CircleCI web app by navigating to Plan > Usage Controls. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# + fixed hidden __name__ = "persist_to_workspace" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PersistToWorkspaceStep#__name__. + + /// Either an absolute path or a path relative to `working_directory` + root: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PersistToWorkspaceStep#root. +// documentation +// > Either an absolute path or a path relative to `working_directory` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Glob identifying file(s), or a non-glob path to a directory to add to the shared workspace. + /// + /// Interpreted as relative to the workspace root. + /// Must not be the workspace root itself + paths: Listing +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PersistToWorkspaceStep#paths. +// documentation +// > Glob identifying file(s), or a non-glob path to a directory to add to the shared workspace. +// > +// > Interpreted as relative to the workspace root. +// > Must not be the workspace root itself +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// Special step used to attach the workflow’s workspace to the current container. + /// + /// The full contents of the workspace are downloaded and copied into the directory the workspace + /// is being attached at. + /// For more information on using workspaces, see the + /// [Using Workspaces to Share Data Between Jobs](https://circleci.com/docs/workspaces/) page. + class AttachWorkspaceStep extends AbstractStep { +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AttachWorkspaceStep# +// documentation +// > Special step used to attach the workflow’s workspace to the current container. +// > +// > The full contents of the workspace are downloaded and copied into the directory the workspace +// > is being attached at. +// > For more information on using workspaces, see the +// > [Using Workspaces to Share Data Between Jobs](https://circleci.com/docs/workspaces/) page. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# + fixed hidden __name__ = "attach_workspace" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AttachWorkspaceStep#__name__. + + /// Directory to attach the workspace to. + at: String +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AttachWorkspaceStep#at. +// documentation +// > Directory to attach the workspace to. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// A conditional step consists of a step with the key `when`. + /// + /// Under the `when` key are the subkeys `condition` and `steps`. + /// The purpose of the `when` step is customizing commands and job configuration to run on custom + /// conditions (determined at config-compile time) that are checked before a workflow runs. + /// See the [Conditional Steps section of the Reusing Config](https://circleci.com/docs/reusing-config/#defining-conditional-steps) + /// document for more details. + class WhenStep { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WhenStep# +// documentation +// > A conditional step consists of a step with the key `when`. +// > +// > Under the `when` key are the subkeys `condition` and `steps`. +// > The purpose of the `when` step is customizing commands and job configuration to run on custom +// > conditions (determined at config-compile time) that are checked before a workflow runs. +// > See the [Conditional Steps section of the Reusing Config](https://circleci.com/docs/reusing-config/#defining-conditional-steps) +// > document for more details. + fixed hidden __name__ = "when" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WhenStep#__name__. + + /// The logic statement that determines whether to execute. + condition: (*LogicStatement|Boolean|String)? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WhenStep#condition. +// documentation +// > The logic statement that determines whether to execute. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A list of steps to execute when the condition is true + steps: Listing? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WhenStep#steps. +// documentation +// > A list of steps to execute when the condition is true +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SimpleStepName# + } + + /// A conditional step consists of a step with the key `unless`. + /// + /// Under the `unless` key are the subkeys `condition` and `steps`. + /// The purpose of the `unless` step is customizing commands and job configuration to run on custom + /// conditions (determined at config-compile time) that are checked before a workflow runs. + /// See the [Conditional Steps section of the Reusing Config](https://circleci.com/docs/reusing-config/#defining-conditional-steps) + /// document for more details. + class UnlessStep { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/UnlessStep# +// documentation +// > A conditional step consists of a step with the key `unless`. +// > +// > Under the `unless` key are the subkeys `condition` and `steps`. +// > The purpose of the `unless` step is customizing commands and job configuration to run on custom +// > conditions (determined at config-compile time) that are checked before a workflow runs. +// > See the [Conditional Steps section of the Reusing Config](https://circleci.com/docs/reusing-config/#defining-conditional-steps) +// > document for more details. + fixed hidden __name__ = "unless" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/UnlessStep#__name__. + + /// The logic statement that determines whether to execute. + condition: (*LogicStatement|Boolean|String)? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/UnlessStep#condition. +// documentation +// > The logic statement that determines whether to execute. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A list of steps to execute when the condition is true + steps: Listing? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/UnlessStep#steps. +// documentation +// > A list of steps to execute when the condition is true +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SimpleStepName# + } + + class Command { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Command# + /// A sequence of steps run inside the calling job of the command. + steps: Listing(!isEmpty) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Command#steps. +// documentation +// > A sequence of steps run inside the calling job of the command. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Step# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + + /// A map of parameter keys. + /// + /// See the [Parameter Syntax](https://circleci.com/docs/reusing-config/#parameter-syntax) + /// section of the [Reusing Config](https://circleci.com/docs/reusing-config/) document for details. + parameters: Mapping? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Command#parameters. +// documentation +// > A map of parameter keys. +// > +// > See the [Parameter Syntax](https://circleci.com/docs/reusing-config/#parameter-syntax) +// > section of the [Reusing Config](https://circleci.com/docs/reusing-config/) document for details. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Parameter# + + /// A string that describes the purpose of the command. + description: String? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Command#description. +// documentation +// > A string that describes the purpose of the command. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + class Parameter { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Parameter# + /// Optional. Used to generate documentation for your orb. + description: String? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Parameter#description. +// documentation +// > Optional. Used to generate documentation for your orb. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The default value for the parameter. If not present, the parameter is implied to be required. + default: (String|Number|Boolean)? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Parameter#default. +// documentation +// > The default value for the parameter. If not present, the parameter is implied to be required. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Required. See [Parameter Types](https://circleci.com/docs/reusing-config/#parameter-types) + /// for details. + type: "string"|"boolean"|"integer"|"enum"|"executor"|"steps"|"env_var_name" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Parameter#type. +// documentation +// > Required. See [Parameter Types](https://circleci.com/docs/reusing-config/#parameter-types) +// > for details. + } + + /// Special step used to upload and store test results for a build. + /// + /// Test results are visible on the CircleCI web application under each build’s *Test Summary* + /// section. + /// Storing test results is useful for timing analysis of your test suites. + /// For more information on storing test results, see the + /// [Collecting Test Data](https://circleci.com/docs/collect-test-data/) page. + /// + /// It is also possible to store test results as a build artifact; to do so, please refer to the + /// [store_artifacts] step. + class StoreTestResults extends AbstractStep { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/StoreTestResults# +// documentation +// > Special step used to upload and store test results for a build. +// > +// > Test results are visible on the CircleCI web application under each build’s *Test Summary* +// > section. +// > Storing test results is useful for timing analysis of your test suites. +// > For more information on storing test results, see the +// > [Collecting Test Data](https://circleci.com/docs/collect-test-data/) page. +// > +// > It is also possible to store test results as a build artifact; to do so, please refer to the +// > `store_artifacts` step. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# + fixed hidden __name__ = "store_test_results" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/StoreTestResults#__name__. + + /// Path (absolute, or relative to your `working_directory`) to directory containing JUnit XML + /// test metadata files, or to a single test file. + path: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/StoreTestResults#path. +// documentation +// > Path (absolute, or relative to your `working_directory`) to directory containing JUnit XML +// > test metadata files, or to a single test file. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// Step to store artifacts (for example logs, binaries, etc) to be available in the web app + /// or through the API. + /// + /// See the [Uploading Artifacts](https://circleci.com/docs/artifacts/) document for more information. + class StoreArtifacts extends AbstractStep { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/StoreArtifacts# +// documentation +// > Step to store artifacts (for example logs, binaries, etc) to be available in the web app +// > or through the API. +// > +// > See the [Uploading Artifacts](https://circleci.com/docs/artifacts/) document for more information. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# + fixed hidden __name__ = "store_artifacts" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/StoreArtifacts#__name__. + + /// Directory in the primary container to save as job artifacts + path: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/StoreArtifacts#path. +// documentation +// > Directory in the primary container to save as job artifacts +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Prefix added to the artifact paths in the artifacts API (default: the directory of the file + /// specified in path) + destination: String? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/StoreArtifacts#destination. +// documentation +// > Prefix added to the artifact paths in the artifacts API (default: the directory of the file +// > specified in path) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// Certain dynamic configuration features accept logic statements as arguments. + /// + /// Logic statements are evaluated to boolean values at configuration compilation time, that is, + /// before the workflow is run. + class LogicStatement { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement# +// documentation +// > Certain dynamic configuration features accept logic statements as arguments. +// > +// > Logic statements are evaluated to boolean values at configuration compilation time, that is, +// > before the workflow is run. + /// True if all arguments are truthy. + and: Listing<*LogicStatement|Boolean|String>?(onlyOneSet(List(this, or, not, equal, matches))) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement#and. +// documentation +// > True if all arguments are truthy. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference local onlyOneSet_708 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement#or. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement#not. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement#equal. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement#matches. + + /// True if any arguments are truthy. + or: Listing<*LogicStatement|Boolean|String>? +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement#or. +// documentation +// > True if any arguments are truthy. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// True if the argument is not truthy. + not: (*LogicStatement|Boolean|String)? +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement#not. +// documentation +// > True if the argument is not truthy. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// True if all arguments evaluate to equal values. + equal: Listing? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement#equal. +// documentation +// > True if all arguments evaluate to equal values. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// True if [value][Match.value] matches the [pattern][Match.pattern]. + matches: Match? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/LogicStatement#matches. +// documentation +// > True if [`value`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.circleci.v2/Config.pkl#L714,C3) matches the [`pattern`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.circleci.v2/Config.pkl#L722,C3). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Match# + } + + /// Tells if only one of the values is not null. + local const function onlyOneSet(values: List): Boolean = +// ^^^^^^^^^^ definition local onlyOneSet_708 +// documentation +// > Tells if only one of the values is not null. +// ^^^^^^ definition local values_709 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + values.filter((it) -> it != null).length == 1 +// ^^^^^^ reference local values_709 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filter(). +// ^^ definition local it_710 +// ^^ reference local it_710 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. + + class Match { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Match# + /// The value to match against + value: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Match#value. +// documentation +// > The value to match against +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A [Java regular expression](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html) + /// used to test against the value. + /// + /// A full match pattern must be provided, prefix matching is not an option. + /// Though, it is recommended to enclose a pattern in `^` and `$` to avoid accidental partial matches. + @SourceCode { language = "RegExp" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Match#language. + pattern: String +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/Match#pattern. +// documentation +// > A [Java regular expression](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html) +// > used to test against the value. +// > +// > A full match pattern must be provided, prefix matching is not an option. +// > Though, it is recommended to enclose a pattern in `^` and `$` to avoid accidental partial matches. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + typealias CalledCommand = Mapping(length == 1) +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/CalledCommand# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/CommandCall# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#length. + + typealias CommandCall = Mapping +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/CommandCall# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + class PipelineValues { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues# + /// A globally unique id representing for the pipeline. + /// + /// Type: string + `pipeline.id`: "<< pipeline.id >>" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.id`. +// documentation +// > A globally unique id representing for the pipeline. +// > +// > Type: string + + /// A project unique integer id for the pipeline. + /// + /// Type: integer + `pipeline.number`: "<< pipeline.number >>" +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.number`. +// documentation +// > A project unique integer id for the pipeline. +// > +// > Type: integer + + /// The URL where the current project is hosted. + /// + /// For example, `https://github.com/circleci/circleci-docs`. + `pipeline.project.git_url`: "<< pipeline.project.git_url >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.project.git_url`. +// documentation +// > The URL where the current project is hosted. +// > +// > For example, `https://github.com/circleci/circleci-docs`. + `pipeline.project.type`: "<< pipeline.project.type >>" +// ^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.project.type`. + `pipeline.git.tag`: "<< pipeline.git.tag >>" +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.git.tag`. + `pipeline.git.branch`: "<< pipeline.git.branch >>" +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.git.branch`. + `pipeline.git.revision`: "<< pipeline.git.revision >>" +// ^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.git.revision`. + `pipeline.git.base_revision`: "<< pipeline.git.base_revision >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.git.base_revision`. + `pipeline.in_setup`: "<< pipeline.in_setup >>" +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.in_setup`. + `pipeline.trigger_source`: "<< pipeline.trigger_source >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_source`. + `pipeline.schedule.name`: "<< pipeline.schedule.name >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.schedule.name`. + `pipeline.schedule.id`: "<< pipeline.schedule.id >>" +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.schedule.id`. + `pipeline.trigger_parameters.circleci.trigger_type`: "<< pipeline.trigger_parameters.circleci.trigger_type >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.circleci.trigger_type`. + `pipeline.trigger_parameters.circleci.event_time`: "<< pipeline.trigger_parameters.circleci.event_time >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.circleci.event_time`. + `pipeline.trigger_parameters.circleci.event_type`: "<< pipeline.trigger_parameters.circleci.event_type >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.circleci.event_type`. + `pipeline.trigger_parameters.circleci.project_id`: "<< pipeline.trigger_parameters.circleci.project_id >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.circleci.project_id`. + `pipeline.trigger_parameters.circleci.actor_id`: "<< pipeline.trigger_parameters.circleci.actor_id >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.circleci.actor_id`. + `pipeline.trigger_parameters.gitlab.type`: "<< pipeline.trigger_parameters.gitlab.type >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.type`. + `pipeline.trigger_parameters.github_app.type`: "<< pipeline.trigger_parameters.github_app.type >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.type`. + `pipeline.trigger_parameters.gitlab.project_id`: "<< pipeline.trigger_parameters.gitlab.project_id >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.project_id`. + `pipeline.trigger_parameters.github_app.project_id`: "<< pipeline.trigger_parameters.github_app.project_id >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.project_id`. + `pipeline.trigger_parameters.gitlab.ref`: "<< pipeline.trigger_parameters.gitlab.ref >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.ref`. + `pipeline.trigger_parameters.github_app.ref`: "<< pipeline.trigger_parameters.github_app.ref >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.ref`. + `pipeline.trigger_parameters.gitlab.checkout_sha`: "<< pipeline.trigger_parameters.gitlab.checkout_sha >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.checkout_sha`. + `pipeline.trigger_parameters.github_app.checkout_sha`: "<< pipeline.trigger_parameters.github_app.checkout_sha >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.checkout_sha`. + `pipeline.trigger_parameters.gitlab.user_id`: "<< pipeline.trigger_parameters.gitlab.user_id >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.user_id`. + `pipeline.trigger_parameters.github_app.user_id`: "<< pipeline.trigger_parameters.github_app.user_id >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.user_id`. + `pipeline.trigger_parameters.gitlab.user_name`: "<< pipeline.trigger_parameters.gitlab.user_name >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.user_name`. + `pipeline.trigger_parameters.github_app.user_name`: "<< pipeline.trigger_parameters.github_app.user_name >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.user_name`. + `pipeline.trigger_parameters.gitlab.user_username`: "<< pipeline.trigger_parameters.gitlab.user_username >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.user_username`. + `pipeline.trigger_parameters.github_app.user_username`: "<< pipeline.trigger_parameters.github_app.user_username >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.user_username`. + `pipeline.trigger_parameters.gitlab.user_avatar`: "<< pipeline.trigger_parameters.gitlab.user_avatar >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.user_avatar`. + `pipeline.trigger_parameters.github_app.user_avatar`: "<< pipeline.trigger_parameters.github_app.user_avatar >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.user_avatar`. + `pipeline.trigger_parameters.gitlab.repo_name`: "<< pipeline.trigger_parameters.gitlab.repo_name >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.repo_name`. + `pipeline.trigger_parameters.github_app.repo_name`: "<< pipeline.trigger_parameters.github_app.repo_name >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.repo_name`. + `pipeline.trigger_parameters.gitlab.repo_url`: "<< pipeline.trigger_parameters.gitlab.repo_url >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.repo_url`. + `pipeline.trigger_parameters.github_app.repo_url`: "<< pipeline.trigger_parameters.github_app.repo_url >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.repo_url`. + `pipeline.trigger_parameters.gitlab.web_url`: "<< pipeline.trigger_parameters.gitlab.web_url >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.web_url`. + `pipeline.trigger_parameters.github_app.web_url`: "<< pipeline.trigger_parameters.github_app.web_url >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.web_url`. + `pipeline.trigger_parameters.gitlab.commit_sha`: "<< pipeline.trigger_parameters.gitlab.commit_sha >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.commit_sha`. + `pipeline.trigger_parameters.github_app.commit_sha`: "<< pipeline.trigger_parameters.github_app.commit_sha >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.commit_sha`. + `pipeline.trigger_parameters.gitlab.commit_title`: "<< pipeline.trigger_parameters.gitlab.commit_title >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.commit_title`. + `pipeline.trigger_parameters.github_app.commit_title`: "<< pipeline.trigger_parameters.github_app.commit_title >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.commit_title`. + `pipeline.trigger_parameters.gitlab.commit_message`: "<< pipeline.trigger_parameters.gitlab.commit_message >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.commit_message`. + `pipeline.trigger_parameters.github_app.commit_message`: "<< pipeline.trigger_parameters.github_app.commit_message >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.commit_message`. + `pipeline.trigger_parameters.gitlab.commit_timestamp`: "<< pipeline.trigger_parameters.gitlab.commit_timestamp >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.commit_timestamp`. + `pipeline.trigger_parameters.github_app.commit_timestamp`: "<< pipeline.trigger_parameters.github_app.commit_timestamp >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.commit_timestamp`. + `pipeline.trigger_parameters.gitlab.commit_author_name`: "<< pipeline.trigger_parameters.gitlab.commit_author_name >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.commit_author_name`. + `pipeline.trigger_parameters.github_app.commit_author_name`: "<< pipeline.trigger_parameters.github_app.commit_author_name >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.commit_author_name`. + `pipeline.trigger_parameters.gitlab.commit_author_email`: "<< pipeline.trigger_parameters.gitlab.commit_author_email >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.commit_author_email`. + `pipeline.trigger_parameters.github_app.commit_author_email`: "<< pipeline.trigger_parameters.github_app.commit_author_email >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.commit_author_email`. + `pipeline.trigger_parameters.gitlab.total_commits_count`: "<< pipeline.trigger_parameters.gitlab.total_commits_count >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.total_commits_count`. + `pipeline.trigger_parameters.github_app.total_commits_count`: "<< pipeline.trigger_parameters.github_app.total_commits_count >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.total_commits_count`. + `pipeline.trigger_parameters.gitlab.branch`: "<< pipeline.trigger_parameters.gitlab.branch >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.branch`. + `pipeline.trigger_parameters.github_app.branch`: "<< pipeline.trigger_parameters.github_app.branch >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.branch`. + `pipeline.trigger_parameters.gitlab.default_branch`: "<< pipeline.trigger_parameters.gitlab.default_branch >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.default_branch`. + `pipeline.trigger_parameters.github_app.default_branch`: "<< pipeline.trigger_parameters.github_app.default_branch >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.github_app.default_branch`. + `pipeline.trigger_parameters.gitlab.x_gitlab_event_id`: "<< pipeline.trigger_parameters.gitlab.x_gitlab_event_id >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.x_gitlab_event_id`. + `pipeline.trigger_parameters.gitlab.is_fork_merge_request`: "<< pipeline.trigger_parameters.gitlab.is_fork_merge_request >>" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues#`pipeline.trigger_parameters.gitlab.is_fork_merge_request`. + } + + /// Pipeline values are available to all pipeline configurations and can be used without previous + /// declaration. + /// + /// For a full list of values and built-in environment variables, see the + /// [Project values and variables guide](https://circleci.com/docs/variables/). + /// + /// For more reference: + hidden pipelineValues: PipelineValues +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/pipelineValues. +// documentation +// > Pipeline values are available to all pipeline configurations and can be used without previous +// > declaration. +// > +// > For a full list of values and built-in environment variables, see the +// > [Project values and variables guide](https://circleci.com/docs/variables/). +// > +// > For more reference: +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PipelineValues# + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/output. + text = "# Generated from CircleCI.pkl. DO NOT EDIT.\n" + super.text +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/text. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + renderer = new YamlRenderer { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/renderer. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/YamlRenderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/converters. + [AbstractStep] = (it) -> Map(it.__name__, it.toMap()) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# +// ^^ definition local it_815 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^ reference local it_815 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep#__name__. +// ^^ reference local it_815 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). + [Dynamic] = (it) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^ definition local it_816 + if (it.hasProperty("__name__")) +// ^^ reference local it_816 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#hasProperty(). + Map(it.__name__, it.toMap().remove("__name__")) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^ reference local it_816 +// ^^ reference local it_816 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#remove(). + else it +// ^^ reference local it_816 + [WorkflowJob] = (it) -> +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WorkflowJob# +// ^^ definition local it_820 + it.toMap() + (it.parameters ?? Map()).toMap() +// ^^ reference local it_820 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). +// ^^ reference local it_820 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/WorkflowJob#parameters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMap(). + } + } + } + diff --git a/pkl-pantrysnapshot/com.circleci.v2/PklProject b/pkl-pantrysnapshot/com.circleci.v2/PklProject new file mode 100755 index 00000000..1b002a5e --- /dev/null +++ b/pkl-pantrysnapshot/com.circleci.v2/PklProject @@ -0,0 +1,24 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Templates for defining [CircleCI](https://circleci.com) configuration. + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 PklProject/package. + version = "1.5.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/com.circleci.v2/examples/build_and_push_image_w_registry_login.pkl b/pkl-pantrysnapshot/com.circleci.v2/examples/build_and_push_image_w_registry_login.pkl new file mode 100755 index 00000000..0f4e8334 --- /dev/null +++ b/pkl-pantrysnapshot/com.circleci.v2/examples/build_and_push_image_w_registry_login.pkl @@ -0,0 +1,63 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + amends ".../Config.pkl" + // Adaptation of https://github.com/CircleCI-Public/aws-ecr-orb/blob/v9.3.7/src/examples/build_and_push_image_w_registry_login.yml#L21-L36 + + version = "2.1" +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/build_and_push_image_w_registry_login.pkl`/version. + + orbs { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/build_and_push_image_w_registry_login.pkl`/orbs. + ["aws-ecr"] = "circleci/aws-ecr@9.0" + ["aws-cli"] = "circleci/aws-cli@5.1" + } + + workflows { +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/build_and_push_image_w_registry_login.pkl`/workflows. + ["build-and-push-image-with-container-registry-login"] { + jobs { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/build_and_push_image_w_registry_login.pkl`/jobs. + new { + ["aws-ecr/build_and_push_image"] { + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/build_and_push_image_w_registry_login.pkl`/parameters. + ["container_registry_login"] = true + ["registry_login"] { + module.run("docker login -u ${HEROKU_USERNAME} -p ${HEROKU_API_KEY}") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/run(). + module.run("docker login -u ${GITHUB_USERNAME} -p ${GITHUB_TOKEN}") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/run(). + module.run("docker login -u ${DOCKERHUB_ID} -p ${DOCKERHUB_PASSWORD}") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/run(). + } + ["auth"] { + (module.OrbStep("aws-cli/setup")) { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/OrbStep(). + role_arn = "arn:aws:iam::123456789012" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/build_and_push_image_w_registry_login.pkl`/role_arn. + } + } + ["repo"] = "my-sample-repo" + ["tag"] = "sampleTag" + ["dockerfile"] = "Dockerfile" + ["path"] = "." + ["region"] = "us-west-2" + } + } + } + } + } + } diff --git a/pkl-pantrysnapshot/com.circleci.v2/examples/concurrent_workflow.pkl b/pkl-pantrysnapshot/com.circleci.v2/examples/concurrent_workflow.pkl new file mode 100755 index 00000000..5099dc97 --- /dev/null +++ b/pkl-pantrysnapshot/com.circleci.v2/examples/concurrent_workflow.pkl @@ -0,0 +1,62 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module com.circleci.v2.examples.concurrent_workflow +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/concurrent_workflow.pkl`/ + + // Adapdation of https://circleci.com/docs/sample-config/#concurrent-workflow + amends "../Config.pkl" + + jobs { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/concurrent_workflow.pkl`/jobs. + ["build"] { + docker { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/concurrent_workflow.pkl`/docker. + new { image = "cimg/base:2023.03" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/concurrent_workflow.pkl`/image. + } + steps { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/concurrent_workflow.pkl`/steps. + "checkout" + module.run(#"echo "this is the build job""#) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/run(). + } + } + ["test"] { + docker { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/concurrent_workflow.pkl`/docker. + new { image = "cimg/base:2023.03"} +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/concurrent_workflow.pkl`/image. + } + steps { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/concurrent_workflow.pkl`/steps. + "checkout" + module.run(#"echo "this is the build job""#) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/run(). + } + } + } + + workflows { +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/concurrent_workflow.pkl`/workflows. + ["build_and_test"] { + jobs { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/concurrent_workflow.pkl`/jobs. + "build" + "test" + } + } + } + diff --git a/pkl-pantrysnapshot/com.circleci.v2/examples/fan_in_fan_out_workflow.pkl b/pkl-pantrysnapshot/com.circleci.v2/examples/fan_in_fan_out_workflow.pkl new file mode 100755 index 00000000..203e3ade --- /dev/null +++ b/pkl-pantrysnapshot/com.circleci.v2/examples/fan_in_fan_out_workflow.pkl @@ -0,0 +1,294 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Adapdation of + /// + /// + /// This example uses [OrbStep] for ad-hoc usage of orbs. + /// Alternatively, orb steps can be defined as their own classes that extend [AbstractStep]. + /// For an example of that, see file `typed_orb_steps.pkl`. + module com.circleci.v2.examples.fan_in_fan_out_workflow +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/ + + amends "../Config.pkl" + + orbs { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/orbs. + ["docker"] = "circleci/docker@1.0.1" + } + + jobs { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/jobs. + ["prepare-dependencies"] { + docker { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/docker. + new { image = "node:current-alpine" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/image. + } + steps { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/steps. + "checkout" + new RunStep { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep# + name = "Compute version number" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/name. + command = #"echo "0.0.${CIRCLE_BUILD_NUM}-${CIRCLE_SHA1:0:7}" | tee version.txt"# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/command. + } + new RestoreCacheStep { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RestoreCacheStep# + keys { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/keys. + #"yarn-deps-{{ checksum "yarn.lock" }}"# + "yarn-deps" + } + } + new RunStep { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep# + name = "yarn install" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/name. + command = "yarn install" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/command. + } + new SaveCacheStep { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/SaveCacheStep# + paths { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/paths. + "node_modules" + } + key = #"yarn-deps-{{ checksum "yarn.lock" }}-{{ epoch }}"# +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/key. + } + new StoreArtifacts { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/StoreArtifacts# + path = "yarn.lock" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/path. + } + new PersistToWorkspaceStep { +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PersistToWorkspaceStep# + root = "." +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/root. + paths { "." } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/paths. + } + } + } + ["build-production"] { + docker { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/docker. + new { image = "node:current-alpine" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/image. + } + steps { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/steps. + new AttachWorkspaceStep { at = "." } +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AttachWorkspaceStep# +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/at. + new RunStep { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep# + name = "Production build" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/name. + command = """ +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/command. + export __BUILD_VERSION="$(cat version.txt)" + yarn build + """ + } + new StoreArtifacts { path = "dist/server.js" } +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/StoreArtifacts# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/path. + new PersistToWorkspaceStep { +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/PersistToWorkspaceStep# + root = "." +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/root. + paths { "." } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/paths. + } + } + } + ["build-docker-image"] { + machine { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/machine. + image = "ubuntu-2004:current" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/image. + } + steps { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/steps. + new AttachWorkspaceStep { at = "." } +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AttachWorkspaceStep# +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/at. + new RunStep { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep# + name = "Setup __BUILD_VERSION envvar" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/name. + command = """ +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/command. + echo 'export __BUILD_VERSION="$(cat version.txt)"' >> "$BASH_ENV" + """ + } + (module.OrbStep("docker/check")) { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/OrbStep(). + registry = "$DOCKER_REGISTRY" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/registry. + } + (module.OrbStep("docker/build")) { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/OrbStep(). + image = "$DOCKER_IMAGE_NAME" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/image. + tag = "$__BUILD_VERSION" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/tag. + registry = "$DOCKER_REGISTRY" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/registry. + } + (module.OrbStep("docker/push")) { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/OrbStep(). + image = "$DOCKER_IMAGE_NAME" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/image. + tag = "$__BUILD_VERSION" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/tag. + registry = "$DOCKER_REGISTRY" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/registry. + } + } + } + ["test"] { + docker { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/docker. + new { image = "node:current-alpine" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/image. + } + parallelism = 2 +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/parallelism. + steps { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/steps. + new AttachWorkspaceStep { at = "." } +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AttachWorkspaceStep# +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/at. + new RunStep { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep# + name = "Run tests" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/name. + command = #""" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/command. + circleci tests glob '**/*.test.ts' | circleci tests split --split-by timings | xargs yarn test:ci + """# + } + new StoreArtifacts { path = "test-results" } +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/StoreArtifacts# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/path. + new StoreTestResults { path = "test-results" } +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/StoreTestResults# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/path. + } + } + ["deploy-docker-image"] { + machine { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/machine. + image = "ubuntu-2004:current" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/image. + } + steps { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/steps. + new AttachWorkspaceStep { at = "." } +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AttachWorkspaceStep# +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/at. + new RunStep { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep# + name = "Setup __BUILD_VERSION envvar" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/name. + command = """ +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/command. + echo 'export __BUILD_VERSION="$(cat version.txt)"' >> "$BASH_ENV" + """ + } + (module.OrbStep("docker/check")) { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/OrbStep(). + registry = "$DOCKER_REGISTRY" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/registry. + } + (module.OrbStep("docker/pull")) { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/OrbStep(). + images = "$DOCKER_REGISTRY/$DOCKER_IMAGE_NAME:$__BUILD_VERSION" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/images. + } + new RunStep { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep# + name = "Tag the image as latest" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/name. + command = """ +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/command. + docker tag $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME:$__BUILD_VERSION $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME:latest + """ + } + (module.OrbStep("docker/push")) { +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/OrbStep(). + image = "$DOCKER_IMAGE_NAME" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/image. + tag = "latest" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/tag. + registry = "$DOCKER_REGISTRY" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/registry. + } + } + } + } + + workflows { +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/workflows. + ["build-test-deploy"] { + jobs { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/jobs. + "prepare-dependencies" + new { + ["build-production"] { + requires { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/requires. + "prepare-dependencies" + } + } + } + new { + ["build-docker-image"] { + context = "docker-hub" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/context. + requires { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/requires. + "build-production" + } + } + } + new { + ["test"] { + requires { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/requires. + "prepare-dependencies" + } + } + } + new { + ["deploy-docker-image"] { + context = "docker-hub" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/context. + requires { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/fan_in_fan_out_workflow.pkl`/requires. + "build-docker-image" + "test" + } + } + } + } + } + } + diff --git a/pkl-pantrysnapshot/com.circleci.v2/examples/typed_orb_steps.pkl b/pkl-pantrysnapshot/com.circleci.v2/examples/typed_orb_steps.pkl new file mode 100755 index 00000000..17a6a2db --- /dev/null +++ b/pkl-pantrysnapshot/com.circleci.v2/examples/typed_orb_steps.pkl @@ -0,0 +1,108 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// This example uses steps from the [circleci/node](https://circleci.com/developer/orbs/orb/circleci/node) orb. + /// + /// It defins local classes that extend [AbstractStep], so that step definitions are type safe. + amends "../Config.pkl" + + /// Install custom versions of Node.js, and optionally NPM/Yarn, in any + /// execution environment (Docker/Linux, macOS, machine) that does not have + /// it preinstalled. + local class NodeInstall extends AbstractStep { +// ^^^^^^^^^^^ definition local NodeInstall_21 +// documentation +// > Install custom versions of Node.js, and optionally NPM/Yarn, in any +// > execution environment (Docker/Linux, macOS, machine) that does not have +// > it preinstalled. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/AbstractStep# + fixed hidden __name__ = "node/install" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/NodeInstall#__name__. + + /// Install Yarn? + /// + /// Default: `false` + `install-yarn`: Boolean? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/NodeInstall#install-yarn. +// documentation +// > Install Yarn? +// > +// > Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Where should Node.js be installed? + /// + /// Default: `/usr/local` + `node-install-dir`: String? +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/NodeInstall#node-install-dir. +// documentation +// > Where should Node.js be installed? +// > +// > Default: `/usr/local` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Specify the full version tag to install. + /// + /// To install the latest version, set the version to `latest`. + /// If unspecified, the version listed in .nvmrc will be installed. + /// If no .nvmrc file exists the active LTS version of Node.js will be installed by default. + /// For a full list of releases, see the following: + `node-version`: String? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/NodeInstall#node-version. +// documentation +// > Specify the full version tag to install. +// > +// > To install the latest version, set the version to `latest`. +// > If unspecified, the version listed in .nvmrc will be installed. +// > If no .nvmrc file exists the active LTS version of Node.js will be installed by default. +// > For a full list of releases, see the following: +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Pick a version of Yarn to install. + /// + /// If no version is specified, the latest stable version will be installed: + `yarn-version`: String? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/NodeInstall#yarn-version. +// documentation +// > Pick a version of Yarn to install. +// > +// > If no version is specified, the latest stable version will be installed: +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + jobs { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/jobs. + ["test"] { + machine { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/machine. + image = "ubuntu-2004:current" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/image. + } + steps { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/steps. + "checkout" + new NodeInstall { `node-version` = "v20.11.1" } +// ^^^^^^^^^^^ reference local NodeInstall_21 +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/node-version. + new RunStep { command = "npm install" } +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/command. + new RunStep { command = "npm test" } +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `Config.pkl`/RunStep# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `examples/typed_orb_steps.pkl`/command. + } + } + } + diff --git a/pkl-pantrysnapshot/com.circleci.v2/tests/Config.pkl b/pkl-pantrysnapshot/com.circleci.v2/tests/Config.pkl new file mode 100755 index 00000000..78982bea --- /dev/null +++ b/pkl-pantrysnapshot/com.circleci.v2/tests/Config.pkl @@ -0,0 +1,43 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module com.circleci.v2.tests.Config +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `tests/Config.pkl`/ + + amends "pkl:test" + + local allExamples = import*("../examples/*.pkl") +// ^^^^^^^^^^^ definition local allExamples_20 + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2 1.5.0 `tests/Config.pkl`/examples. + for (example in allExamples.keys) { +// ^^^^^^^ definition local example_23 +// ^^^^^^^^^^^ reference local allExamples_20 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#keys. + [example.drop("../examples/".length).replaceLast("pkl", "yaml")] { +// ^^^^^^^ reference local example_23 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceLast(). + allExamples[example].output.text +// ^^^^^^^^^^^ reference local allExamples_20 +// ^^^^^^^ reference local example_23 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + } + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/PklProject b/pkl-pantrysnapshot/com.influxdata.telegraf/PklProject new file mode 100755 index 00000000..2834892a --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/PklProject @@ -0,0 +1,30 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Templates for configuring [Telegraf](https://docs.influxdata.com/telegraf), + /// a plugin-driven server agent for collecting and reporting metrics. + amends "../basePklProject.pkl" + + dependencies { +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 PklProject/dependencies. + ["toml"] = import("../pkl.toml/PklProject") + } + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 PklProject/package. + version = "1.5.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/Telegraf.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/Telegraf.pkl new file mode 100755 index 00000000..8bea5848 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/Telegraf.pkl @@ -0,0 +1,561 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Definitions for a [Telegraf configuration](https://docs.influxdata.com/telegraf/v1.17/administration/configuration/). + /// + /// This API nests data formats as a child object of plugins. + /// For instance, here is an example of a socket listener which uses the json data format: + /// ``` + /// import "package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf@#/plugins/parsers/JsonInputDataFormat.pkl" + /// + /// inputs { + /// socket_listener { + /// new { + /// service_address = "tcp://:8085" + /// data_format = new JsonInputDataFormat { + /// json_query = "foo.bar" + /// tag_keys { + /// "my-tag-1" + /// "my-tag-2" + /// } + /// json_name_key = "my_measurement" + /// json_time_key = "time" + /// } + /// } + /// } + /// } + /// ``` + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/minPklVersion. + open module com.influxdata.telegraf.Telegraf +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/ + + import "plugins/Plugin.pkl" + import "plugins/inputs/CpuInput.pkl" + import "plugins/inputs/DiskInput.pkl" + import "plugins/inputs/ExecInput.pkl" + import "plugins/inputs/FileInput.pkl" + import "plugins/inputs/HttpInput.pkl" + import "plugins/inputs/Jolokia2AgentInput.pkl" + import "plugins/inputs/NetInput.pkl" + import "plugins/inputs/PrometheusInput.pkl" + import "plugins/inputs/SocketListenerInput.pkl" + import "plugins/inputs/SolrInput.pkl" + import "plugins/inputs/X509CertInput.pkl" + import "plugins/outputs/DiscardOutput.pkl" + import "plugins/outputs/FileOutput.pkl" + import "plugins/outputs/OpenTelemetryOutput.pkl" + import "plugins/outputs/PrometheusClientOutput.pkl" + import "plugins/processors/StarlarkProcessor.pkl" + + /// Telegraf has a few options you can configure under the [agent] section of the config. + agent: AgentConfig? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/agent. +//documentation +//> Telegraf has a few options you can configure under the [`agent`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/Telegraf.pkl#L62,C1) section of the config. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig# + + /// Output plugins write metrics to a location. + /// + /// Outputs commonly write to databases, network services, and messaging systems. + outputs: Outputs? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/outputs. +//documentation +//> Output plugins write metrics to a location. +//> +//> Outputs commonly write to databases, network services, and messaging systems. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Outputs# + + /// Input plugins gather and create metrics. + /// + /// They support both polling and event driven operation. + inputs: Inputs? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/inputs. +//documentation +//> Input plugins gather and create metrics. +//> +//> They support both polling and event driven operation. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs# + + /// Processor plugins process metrics as they pass through and immediately emit results + /// based on the values they process. + /// + /// For example, this could be printing all metrics or adding a tag to all metrics that pass through. + processors: Processors? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/processors. +//documentation +//> Processor plugins process metrics as they pass through and immediately emit results +//> based on the values they process. +//> +//> For example, this could be printing all metrics or adding a tag to all metrics that pass through. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Processors# + + /// All metrics being gathered on this host will be tagged with the tags specified here. + global_tags: Mapping? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/global_tags. +//documentation +//> All metrics being gathered on this host will be tagged with the tags specified here. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + open class Outputs { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Outputs# + /// This plugin writes telegraf metrics to files. + file: Listing? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Outputs#file. +// documentation +// > This plugin writes telegraf metrics to files. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/FileOutput.pkl`/ + + /// This output plugin simply drops all metrics that are sent to it. + /// + /// It is only meant to be used for testing purposes. + discard: Listing? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Outputs#discard. +// documentation +// > This output plugin simply drops all metrics that are sent to it. +// > +// > It is only meant to be used for testing purposes. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/DiscardOutput.pkl`/ + + /// This plugin starts a [Prometheus](https://prometheus.io) Client. + /// + /// Tt exposes all metrics on `/metrics` (default) to be polled by a Prometheus server. + prometheus_client: Listing? +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Outputs#prometheus_client. +// documentation +// > This plugin starts a [Prometheus](https://prometheus.io) Client. +// > +// > Tt exposes all metrics on `/metrics` (default) to be polled by a Prometheus server. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/ + + /// This plugin sends metrics to [OpenTelemetry](https://opentelemetry.io) servers and agents via gRPC. + opentelemetry: Listing? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Outputs#opentelemetry. +// documentation +// > This plugin sends metrics to [OpenTelemetry](https://opentelemetry.io) servers and agents via gRPC. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/ + } + + open class Inputs { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs# + /// The file plugin parses the complete contents of a file every interval using the selected input data format. + /// + /// Note: If you wish to parse only newly appended lines use the tail input plugin instead. + /// + file: Listing? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs#file. +// documentation +// > The file plugin parses the complete contents of a file every interval using the selected input data format. +// > +// > Note: If you wish to parse only newly appended lines use the tail input plugin instead. +// > +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/FileInput.pkl`/ + + /// The prometheus input plugin gathers metrics from HTTP servers exposing metrics in Prometheus format. + /// + /// + prometheus: Listing? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs#prometheus. +// documentation +// > The prometheus input plugin gathers metrics from HTTP servers exposing metrics in Prometheus format. +// > +// > +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/ + + /// The Socket Listener is a service input plugin that listens for messages + /// from streaming (tcp, unix) or datagram (udp, unixgram) protocols. + /// + /// The plugin expects messages in the + /// [Telegraf Input Data Formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md). + socket_listener: Listing? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs#socket_listener. +// documentation +// > The Socket Listener is a service input plugin that listens for messages +// > from streaming (tcp, unix) or datagram (udp, unixgram) protocols. +// > +// > The plugin expects messages in the +// > [Telegraf Input Data Formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/ + + /// The [Disk input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/disk/README.md) + /// gathers metrics about disk usage by mount point. + disk: Listing? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs#disk. +// documentation +// > The [Disk input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/disk/README.md) +// > gathers metrics about disk usage by mount point. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/DiskInput.pkl`/ + + /// The [CPU input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/cpu/README.md) + /// gathers metrics about cpu usage. + cpu: Listing? +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs#cpu. +// documentation +// > The [CPU input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/cpu/README.md) +// > gathers metrics about cpu usage. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/CpuInput.pkl`/ + + /// The [HTTP input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/http/README.md) + /// collects metrics from one or more HTTP(S) endpoints. + /// + /// The endpoint should have metrics formatted in one of the supported input data formats. + /// Each data format has its own unique set of configuration options which can be added to the input configuration. + http: Listing? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs#http. +// documentation +// > The [HTTP input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/http/README.md) +// > collects metrics from one or more HTTP(S) endpoints. +// > +// > The endpoint should have metrics formatted in one of the supported input data formats. +// > Each data format has its own unique set of configuration options which can be added to the input configuration. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/ + + /// The [net input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/net/NET_README.md) + /// gathers metrics about network interface and protocol usage (Linux only). + net: Listing? +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs#net. +// documentation +// > The [net input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/net/NET_README.md) +// > gathers metrics about network interface and protocol usage (Linux only). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/NetInput.pkl`/ + + /// The [exec input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/exec/README.md) + /// read metrics from one or more commands that can output to stdout. + exec: Listing? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs#exec. +// documentation +// > The [exec input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/exec/README.md) +// > read metrics from one or more commands that can output to stdout. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/ExecInput.pkl`/ + + /// The [Solr input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/solr/README.md) + /// gathers metrics from one or more Solr servers + solr: Listing? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs#solr. +// documentation +// > The [Solr input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/solr/README.md) +// > gathers metrics from one or more Solr servers +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SolrInput.pkl`/ + + /// [Jolokia Agent Input Plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/jolokia2_agent) + /// + /// Reads JMX metrics from one or more Jolokia agent REST endpoints. + jolokia2_agent: Listing? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs#jolokia2_agent. +// documentation +// > [Jolokia Agent Input Plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/jolokia2_agent) +// > +// > Reads JMX metrics from one or more Jolokia agent REST endpoints. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/ + + /// The [X509 Cert Input Plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/x509_cert/README.md). + /// + /// Provides information about X509 certificates accessible via local file, tcp, udp, https or smtp protocol + x509_cert: Listing? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Inputs#x509_cert. +// documentation +// > The [X509 Cert Input Plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/x509_cert/README.md). +// > +// > Provides information about X509 certificates accessible via local file, tcp, udp, https or smtp protocol +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/ + } + + open class Processors { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Processors# + /// The [starlark processor](https://github.com/influxdata/telegraf/tree/master/plugins/processors/starlark) calls a + /// Starlark function for each matched metric, allowing for custom programmatic metric processing. + starlark: Listing? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/Processors#starlark. +// documentation +// > The [starlark processor](https://github.com/influxdata/telegraf/tree/master/plugins/processors/starlark) calls a +// > Starlark function for each matched metric, allowing for custom programmatic metric processing. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/processors/StarlarkProcessor.pkl`/ + } + + open class AgentConfig { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig# + /// Default data collection interval for all inputs. + interval: Duration? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#interval. +// documentation +// > Default data collection interval for all inputs. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Rounds collection interval to [interval]. + /// + /// For example, `interval = 10.s` collects on :00, :10, :20, etc. + round_interval: Boolean? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#round_interval. +// documentation +// > Rounds collection interval to [`interval`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/Telegraf.pkl#L166,C3). +// > +// > For example, `interval = 10.s` collects on :00, :10, :20, etc. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Telegraf will send metrics to outputs in batches of at most [metric_batch_size] metrics. + /// + /// This controls the size of writes that Telegraf sends to output plugins. + metric_batch_size: Int? +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#metric_batch_size. +// documentation +// > Telegraf will send metrics to outputs in batches of at most [`metric_batch_size`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/Telegraf.pkl#L176,C3) metrics. +// > +// > This controls the size of writes that Telegraf sends to output plugins. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Maximum number of unwritten metrics per output. + /// + /// Increasing this value allows for longer periods of output downtime + /// without dropping metrics at the cost of higher maximum memory usage. + metric_buffer_limit: Int? +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#metric_buffer_limit. +// documentation +// > Maximum number of unwritten metrics per output. +// > +// > Increasing this value allows for longer periods of output downtime +// > without dropping metrics at the cost of higher maximum memory usage. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Collection jitter is used to jitter the collection by a random [interval]. + /// + /// Each plugin will sleep for a random time within jitter before collecting. + /// This can be used to avoid many plugins querying things like sysfs + /// at the same time, which can have a measurable effect on the system. + collection_jitter: Duration? +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#collection_jitter. +// documentation +// > Collection jitter is used to jitter the collection by a random [`interval`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/Telegraf.pkl#L166,C3). +// > +// > Each plugin will sleep for a random time within jitter before collecting. +// > This can be used to avoid many plugins querying things like sysfs +// > at the same time, which can have a measurable effect on the system. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Default flushing [interval] for all outputs. + /// + /// Maximum flush interval is `flush_interval + flush_jitter`. + flush_interval: Duration? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#flush_interval. +// documentation +// > Default flushing [`interval`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/Telegraf.pkl#L166,C3) for all outputs. +// > +// > Maximum flush interval is `flush_interval + flush_jitter`. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Default flush jitter for all outputs. + /// + /// This jitters the flush [interval] by a random amount. + /// This is primarily to avoid large write spikes for users running a large number of telegraf instances. + /// For example, a jitter of 5s and interval 10s means flushes will happen every 10-15s. + flush_jitter: Duration? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#flush_jitter. +// documentation +// > Default flush jitter for all outputs. +// > +// > This jitters the flush [`interval`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/Telegraf.pkl#L166,C3) by a random amount. +// > This is primarily to avoid large write spikes for users running a large number of telegraf instances. +// > For example, a jitter of 5s and interval 10s means flushes will happen every 10-15s. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Collected metrics are rounded to the precision specified as an [interval]. + /// + /// Precision will NOT be used for service inputs. + /// It is up to each individual service input to set the timestamp at the appropriate precision. + precision: ("ns"|"us"|"ms"|"s")? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#precision. +// documentation +// > Collected metrics are rounded to the precision specified as an [`interval`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/Telegraf.pkl#L166,C3). +// > +// > Precision will NOT be used for service inputs. +// > It is up to each individual service input to set the timestamp at the appropriate precision. + + /// Log at debug level. + debug: Boolean? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#debug. +// documentation +// > Log at debug level. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Log only error level messages. + quiet: Boolean? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#quiet. +// documentation +// > Log only error level messages. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Name of the file to be logged to when using the "file" logtarget. + /// + /// If set to the empty string, logs are written to stderr. + logfile: String? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#logfile. +// documentation +// > Name of the file to be logged to when using the "file" logtarget. +// > +// > If set to the empty string, logs are written to stderr. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The logfile will be rotated after the time interval specified. + /// + /// When set to `0.s`, no time based rotation is performed. + logfile_rotation_interval: Duration? +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#logfile_rotation_interval. +// documentation +// > The logfile will be rotated after the time interval specified. +// > +// > When set to `0.s`, no time based rotation is performed. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// The logfile will be rotated when it becomes larger than the specified size. + /// + /// When set to `0.b`, no size based rotation is performed. + logfile_rotation_max_size: DataSize? +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#logfile_rotation_max_size. +// documentation +// > The logfile will be rotated when it becomes larger than the specified size. +// > +// > When set to `0.b`, no size based rotation is performed. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Maximum number of rotated archives to keep, any older logs are deleted. + /// + /// If set to -1, no archives are removed. + logfile_rotation_max_archives: Int? +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#logfile_rotation_max_archives. +// documentation +// > Maximum number of rotated archives to keep, any older logs are deleted. +// > +// > If set to -1, no archives are removed. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Override default hostname, if empty use os.Hostname(). + hostname: String? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#hostname. +// documentation +// > Override default hostname, if empty use os.Hostname(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// If set to true, do no set the "host" tag in the telegraf agent. + omit_hostname: Boolean? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/AgentConfig#omit_hostname. +// documentation +// > If set to true, do no set the "host" tag in the telegraf agent. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + /// Telegraf uses golang's built-in `time.ParseDuration` underneath the hood. + /// + local durationConverter = (dur: Duration) -> +// ^^^^^^^^^^^^^^^^^ definition local durationConverter_242 +// documentation +// > Telegraf uses golang's built-in `time.ParseDuration` underneath the hood. +// > +// ^^^ definition local dur_244 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + // Golang doesn't support days, so convert down to hours. + if (dur.unit == "d") +// ^^^ reference local dur_244 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#unit. + durationConverter.apply(dur.toUnit("h")) +// ^^^^^^^^^^^^^^^^^ reference local durationConverter_242 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^ reference local dur_244 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#toUnit(). + else + let (unit = dur.unit) +// ^^^^ definition local unit_249 +// ^^^ reference local dur_244 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#unit. + // Most of Pkl's unit names are exact matches for Golang's unit names, except `min` needs to turn into `m`. + let (telegrafUnit = if (unit == "min") "m" else unit) +// ^^^^^^^^^^^^ definition local telegrafUnit_251 +// ^^^^ reference local unit_249 +// ^^^^ reference local unit_249 + "\(dur.value)\(telegrafUnit)" +// ^^^ reference local dur_244 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#value. +// ^^^^^^^^^^^^ reference local telegrafUnit_251 + + /// Telegraf uses github.coim/alecthomas/units to parse data sizes. + /// The parser is pretty lenient; see tests here: + /// + local dataSizeConverter = (size: DataSize) -> +// ^^^^^^^^^^^^^^^^^ definition local dataSizeConverter_254 +// documentation +// > Telegraf uses github.coim/alecthomas/units to parse data sizes. +// > The parser is pretty lenient; see tests here: +// > +// ^^^^ definition local size_257 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + let (unit = size.unit) +// ^^^^ definition local unit_258 +// ^^^^ reference local size_257 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize#unit. + let (telegrafUnit = +// ^^^^^^^^^^^^ definition local telegrafUnit_259 + if (unit.length == 3) unit[0].toUpperCase() + unit[1] + unit[2].toUpperCase() +// ^^^^ reference local unit_258 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^ reference local unit_258 +// ^^^^ reference local unit_258 +// ^^^^ reference local unit_258 + else if (unit.length == 2) unit.toUpperCase() +// ^^^^ reference local unit_258 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^ reference local unit_258 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toUpperCase(). + else "") + "\(size.value)\(telegrafUnit)" +// ^^^^ reference local size_257 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize#value. +// ^^^^^^^^^^^^ reference local telegrafUnit_259 + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/output. + renderer = (Plugin.output.renderer) { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/renderer. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#renderer. + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `Telegraf.pkl`/converters. + [Duration] = durationConverter +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# +// ^^^^^^^^^^^^^^^^^ reference local durationConverter_242 + [DataSize] = dataSizeConverter +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# +// ^^^^^^^^^^^^^^^^^ reference local dataSizeConverter_254 + } + } + } + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/examples/InputJolokiaAgent.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/examples/InputJolokiaAgent.pkl new file mode 100755 index 00000000..cb948af1 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/examples/InputJolokiaAgent.pkl @@ -0,0 +1,68 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + amends "../Telegraf.pkl" + + agent { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/agent. + collection_jitter = 0.s +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/collection_jitter. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#s. + debug = true +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/debug. + flush_interval = 30.s +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/flush_interval. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#s. + flush_jitter = 0.s +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/flush_jitter. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#s. + interval = 30.s +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/interval. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#s. + } + + inputs { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/inputs. + jolokia2_agent { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/jolokia2_agent. + new { + urls { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/urls. + "http://localhost:7883" + } + response_timeout = 3.s +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/response_timeout. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#s. + tls_cert = "/var/private/client.pem" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/tls_cert. + tls_key = "/var/private/client-key.pem" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/tls_key. + metric { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/metric. + new { + name = "java_runtime" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/name. + mbean = "java.lang:type=Runtime" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/mbean. + paths { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/InputJolokiaAgent.pkl`/paths. + "Uptime" + } + } + } + } + } + } + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/examples/opentelemetry-output.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/examples/opentelemetry-output.pkl new file mode 100755 index 00000000..d905a50a --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/examples/opentelemetry-output.pkl @@ -0,0 +1,59 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + amends "../Telegraf.pkl" + + outputs { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/outputs. + opentelemetry { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/opentelemetry. + new { + service_address = "localhost:4312" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/service_address. + timeout = 10.s +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/timeout. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#s. + tls_ca = "/path/to/ca/cert" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/tls_ca. + tls_cert = "/path/to/cert" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/tls_cert. + tls_key = "/path/to/key" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/tls_key. + tls_server_name = "tls-server.com" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/tls_server_name. + compression = "gzip" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/compression. + coralogix { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/coralogix. + application = "myapp" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/application. + private_key = "my secret value" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/private_key. + subsystem = "my subsystem" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/subsystem. + } + attributes { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/attributes. + ["service.name"] = "foo" + ["service.version"] = "1.0.0" + } + headers { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/opentelemetry-output.pkl`/headers. + ["x-api-key"] = "my-api-key" + } + } + } + } + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/examples/simple.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/examples/simple.pkl new file mode 100755 index 00000000..8ec839cf --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/examples/simple.pkl @@ -0,0 +1,73 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + amends "../Telegraf.pkl" + + import "../plugins/serializers/JsonOutputDataFormat.pkl" + + global_tags { +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/global_tags. + ["user"] = "alice" + } + + inputs { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/inputs. + http { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/http. + new { + method = "GET" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/method. + urls { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/urls. + "https://server.company.org/metrics" + } + } + } + cpu { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/cpu. + new { + percpu = false +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/percpu. + totalcpu = true +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/totalcpu. + tags { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/tags. + ["tag1"] = "foo" + ["tag2"] = "bar" + } + } + } + } + + outputs { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/outputs. + file { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/file. + new { + files { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/files. + "my/file.txt" + } + data_format = new JsonOutputDataFormat { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/data_format. +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/serializers/JsonOutputDataFormat.pkl`/ + json_timestamp_units = 5.s +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/simple.pkl`/json_timestamp_units. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#s. + } + } + } + } + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/examples/x509CertInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/examples/x509CertInput.pkl new file mode 100755 index 00000000..fc2c07ae --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/examples/x509CertInput.pkl @@ -0,0 +1,61 @@ + //===----------------------------------------------------------------------===// + // Copyright © 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + amends "../Telegraf.pkl" + + inputs { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/inputs. + x509_cert { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/x509_cert. + new { + sources { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/sources. + "tcp://example.org:443" + "https://influxdata.com:443" + "smtp://mail.localhost:25" + "udp://127.0.0.1:4433" + "/etc/ssl/certs/ssl-cert-snakeoil.pem" + "/etc/mycerts/*.mydomain.org.pem" + "file:///path/to/*.pem" + "jks:///etc/mycerts/keystore.jks" + "pkcs12:///etc/mycerts/keystore.p12" + } + timeout = 5.s +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/timeout. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#s. + server_name = "myhost.example.com" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/server_name. + exclude_only_roots = true +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/exclude_only_roots. + pad_serial_with_zeroes = true +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/pad_serial_with_zeroes. + password = "hunter2" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/password. + tls_ca = "/etc/telegraf/ca.pem" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/tls_ca. + tls_cert = "/etc/telegraf/cert.pem" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/tls_cert. + tls_key = "/etc/telegraf/key.pem" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/tls_key. + tls_server_name = "myhost.example.com" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/tls_server_name. + use_proxy = true +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/use_proxy. + proxy_url = "http://localhost:8888" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `examples/x509CertInput.pkl`/proxy_url. + } + } + } + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/Plugin.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/Plugin.pkl new file mode 100755 index 00000000..f307fe1d --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/Plugin.pkl @@ -0,0 +1,178 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Telegraf is a plugin-driven agent that collects, processes, aggregates, and writes metrics. + /// + /// Telegraf supports four categories of plugins including input, output, aggregator, and processor. + /// + /// Docs: + /// + /// Filters can be configured per input, output, processor, or aggregator. + /// + /// Docs: + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/minPklVersion. + abstract module com.influxdata.telegraf.plugins.Plugin +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/ + + import "@toml/toml.pkl" + + /// An array of glob pattern strings. + /// + /// Only metrics whose measurement name matches a pattern in this list are emitted. + namepass: Listing? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/namepass. +//documentation +//> An array of glob pattern strings. +//> +//> Only metrics whose measurement name matches a pattern in this list are emitted. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The inverse of [namepass]. + /// + /// If a match is found the metric is discarded. + /// This is tested on metrics after they have passed the [namepass] test. + namedrop: Listing? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/namedrop. +//documentation +//> The inverse of [`namepass`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/Plugin.pkl#L33,C1). +//> +//> If a match is found the metric is discarded. +//> This is tested on metrics after they have passed the [`namepass`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/Plugin.pkl#L33,C1) test. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A table mapping tag keys to arrays of glob pattern strings. + /// + /// Only metrics that contain a tag key in the table and a tag value matching one of its patterns is emitted. + tagpass: Mapping>? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/tagpass. +//documentation +//> A table mapping tag keys to arrays of glob pattern strings. +//> +//> Only metrics that contain a tag key in the table and a tag value matching one of its patterns is emitted. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The inverse of [tagpass]. + /// + /// If a match is found the metric is discarded. + /// This is tested on metrics after they have passed the [tagpass] test. + tagdrop: Mapping>? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/tagdrop. +//documentation +//> The inverse of [`tagpass`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/Plugin.pkl#L44,C1). +//> +//> If a match is found the metric is discarded. +//> This is tested on metrics after they have passed the [`tagpass`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/Plugin.pkl#L44,C1) test. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// An array of glob pattern strings. + /// + /// Only fields whose field key matches a pattern in this list are emitted. + fieldpass: Listing? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/fieldpass. +//documentation +//> An array of glob pattern strings. +//> +//> Only fields whose field key matches a pattern in this list are emitted. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The inverse of [fieldpass]. + /// + /// Fields with a field key matching one of the patterns will be discarded from the metric. + /// This is tested on metrics after they have passed the [fieldpass] test. + fielddrop: Listing? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/fielddrop. +//documentation +//> The inverse of [`fieldpass`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/Plugin.pkl#L55,C1). +//> +//> Fields with a field key matching one of the patterns will be discarded from the metric. +//> This is tested on metrics after they have passed the [`fieldpass`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/Plugin.pkl#L55,C1) test. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// An array of glob pattern strings. + /// + /// Only tags with a tag key matching one of the patterns are emitted. + /// In contrast to [tagpass], which will pass an entire metric based on its tag, + /// [taginclude] removes all non matching tags from the metric. + /// Any tag can be filtered including global tags and the agent `host` tag. + taginclude: Listing? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/taginclude. +//documentation +//> An array of glob pattern strings. +//> +//> Only tags with a tag key matching one of the patterns are emitted. +//> In contrast to [`tagpass`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/Plugin.pkl#L44,C1), which will pass an entire metric based on its tag, +//> [`taginclude`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/Plugin.pkl#L69,C1) removes all non matching tags from the metric. +//> Any tag can be filtered including global tags and the agent `host` tag. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The inverse of [taginclude]. + /// + /// Tags with a tag key matching one of the patterns will be discarded from the metric. + /// Any tag can be filtered including global tags and the agent `host` tag + tagexclude: Listing? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/tagexclude. +//documentation +//> The inverse of [`taginclude`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/Plugin.pkl#L69,C1). +//> +//> Tags with a tag key matching one of the patterns will be discarded from the metric. +//> Any tag can be filtered including global tags and the agent `host` tag +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/output. + renderer = new toml.Renderer { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/renderer. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/Plugin.pkl`/converters. + // The Pkl config defines data formats as a nested object. + // Telegraf defines this as a flat object, + // so we inline the data format into the top-level plugin. + ["*"] = (value) -> +// ^^^^^ definition local value_83 + if (value is module) +// ^^^^^ reference local value_83 + let (m = value.toMap()) +// ^ definition local m_85 +// ^^^^^ reference local value_83 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). + m.remove("data_format") + ((m.getOrNull("data_format") as Typed?)?.toMap() ?? Map()) +// ^ reference local m_85 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#remove(). +// ^ reference local m_85 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#getOrNull(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + else value +// ^^^^^ reference local value_83 + } + } + } + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/CpuInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/CpuInput.pkl new file mode 100755 index 00000000..6c0ab20b --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/CpuInput.pkl @@ -0,0 +1,68 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The `cpu` plugin gather metrics on the system CPUs. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/CpuInput.pkl`/minPklVersion. + module com.influxdata.telegraf.plugins.inputs.CpuInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/CpuInput.pkl`/ + + extends "Input.pkl" + + /// Whether to report per-CPU stats or not. + /// + /// Default: `true` + percpu: Boolean? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/CpuInput.pkl`/percpu. +//documentation +//> Whether to report per-CPU stats or not. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Whether to report total system CPU stats or not. + /// + /// Default: `true` + totalcpu: Boolean? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/CpuInput.pkl`/totalcpu. +//documentation +//> Whether to report total system CPU stats or not. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// If true, collect raw CPU time metrics. + /// + /// Default: `false` + collect_cpu_time: Boolean? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/CpuInput.pkl`/collect_cpu_time. +//documentation +//> If true, collect raw CPU time metrics. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// If true, compute and report the sum of all non-idle CPU states. + /// + /// Default: `false` + report_active: Boolean? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/CpuInput.pkl`/report_active. +//documentation +//> If true, compute and report the sum of all non-idle CPU states. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/DiskInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/DiskInput.pkl new file mode 100755 index 00000000..b047a614 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/DiskInput.pkl @@ -0,0 +1,52 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The [disk input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/disk/README.md) + /// gathers metrics about disk usage. + /// + /// Note that `used_percent` is calculated by doing `used / (used + free)`, + /// _not_ `used / total`, which is how the unix `df` command does it. + /// See for more details. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/DiskInput.pkl`/minPklVersion. + module com.influxdata.telegraf.plugins.inputs.DiskInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/DiskInput.pkl`/ + + extends "Input.pkl" + + /// By default stats will be gathered for all mount points. + /// + /// Set mount_points will restrict the stats to only the specified mount points. + mount_points: Listing? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/DiskInput.pkl`/mount_points. +//documentation +//> By default stats will be gathered for all mount points. +//> +//> Set mount_points will restrict the stats to only the specified mount points. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + typealias FsType = "tmpfs"|"devtmpfs"|"devfs"|"iso9660"|"overlay"|"aufs"|"squashfs" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/DiskInput.pkl`/FsType# + + /// Ignore mount points by filesystem type. + ignore_fs: Listing? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/DiskInput.pkl`/ignore_fs. +//documentation +//> Ignore mount points by filesystem type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/DiskInput.pkl`/FsType# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/ExecInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/ExecInput.pkl new file mode 100755 index 00000000..85b2b68d --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/ExecInput.pkl @@ -0,0 +1,98 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// [Exec Input Plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/exec/README.md) + /// + /// The exec plugin executes all the commands in parallel on every interval and parses metrics from their output in any one of the accepted Input Data Formats. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/ExecInput.pkl`/minPklVersion. + module com.influxdata.telegraf.plugins.inputs.ExecInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/ExecInput.pkl`/ + + extends "Input.pkl" + + import ".../parsers/InputDataFormat.pkl" + + /// Commands array. + commands: Listing +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/ExecInput.pkl`/commands. +//documentation +//> Commands array. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Environment variables. + hidden env: Mapping +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/ExecInput.pkl`/env. +// documentation +// > Environment variables. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The environment variables as exposed to the exec input plugin. + /// + /// This is an internal property that is derived from [env]. + fixed environment: Listing = env +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/ExecInput.pkl`/environment. +// documentation +// > The environment variables as exposed to the exec input plugin. +// > +// > This is an internal property that is derived from [`env`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/inputs/ExecInput.pkl#L30,C1). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/ExecInput.pkl`/env. + .toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + .entries +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. + .map((entry) -> "\(entry.key)=\(entry.value)") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^^ definition local entry_38 +// ^^^^^ reference local entry_38 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#key. +// ^^^^^ reference local entry_38 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#value. + .toListing() +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toListing(). + + /// Timeout for each command to complete. + timeout: Duration? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/ExecInput.pkl`/timeout. +//documentation +//> Timeout for each command to complete. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Measurement name suffix (for separating different commands). + name_suffix: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/ExecInput.pkl`/name_suffix. +//documentation +//> Measurement name suffix (for separating different commands). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The [input data format](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md) + /// to consume. + /// + /// Each data format has its own unique set of configuration options. + data_format: InputDataFormat? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/ExecInput.pkl`/data_format. +//documentation +//> The [input data format](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md) +//> to consume. +//> +//> Each data format has its own unique set of configuration options. +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/InputDataFormat.pkl`/ + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/FileInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/FileInput.pkl new file mode 100755 index 00000000..57702cc3 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/FileInput.pkl @@ -0,0 +1,65 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The `file` plugin parses the **complete** contents of a file **every interval** + /// using the selected input data format. + /// + /// **Note:** If you wish to parse only newly appended lines use the `tail` input plugin instead. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/FileInput.pkl`/minPklVersion. + open module com.influxdata.telegraf.plugins.inputs.FileInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/FileInput.pkl`/ + + extends "Input.pkl" + + import "../parsers/InputDataFormat.pkl" + + /// Files to parse each interval. + /// + /// Accept standard unix glob matching rules, as well as `**` to match recursive files and directories. + files: Listing +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/FileInput.pkl`/files. +//documentation +//> Files to parse each interval. +//> +//> Accept standard unix glob matching rules, as well as `**` to match recursive files and directories. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Name a tag containing the name of the file the data was parsed from. + /// + /// Leave empty to disable. + file_tag: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/FileInput.pkl`/file_tag. +//documentation +//> Name a tag containing the name of the file the data was parsed from. +//> +//> Leave empty to disable. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The [input data format](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md) + /// to consume. + /// + /// Each data format has its own unique set of configuration options. + data_format: InputDataFormat? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/FileInput.pkl`/data_format. +//documentation +//> The [input data format](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md) +//> to consume. +//> +//> Each data format has its own unique set of configuration options. +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/InputDataFormat.pkl`/ + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/HttpInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/HttpInput.pkl new file mode 100755 index 00000000..dcd2548b --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/HttpInput.pkl @@ -0,0 +1,142 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The HTTP input plugin collects metrics from one or more HTTP(S) endpoints. + /// + /// The endpoint should have metrics formatted in one of the supported + /// [input data formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md). + /// Each data format has its own unique set of configuration options which can be added to the input configuration. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/minPklVersion. + open module com.influxdata.telegraf.plugins.inputs.HttpInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/ + + extends "./Input.pkl" + + import "../parsers/InputDataFormat.pkl" + + /// One or more URLs from which to read formatted metrics. + urls: Listing +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/urls. +//documentation +//> One or more URLs from which to read formatted metrics. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// HTTP method. + method: "GET"|"POST"|"PUT"|"PATCH" +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/method. +//documentation +//> HTTP method. + + /// Optional HTTP headers. + headers: Mapping? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/headers. +//documentation +//> Optional HTTP headers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// HTTP entity-body to send with POST/PUT requests. + body: String? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/body. +//documentation +//> HTTP entity-body to send with POST/PUT requests. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// HTTP Content-Encoding for write request body. + /// + /// Can be set to "gzip" to compress body or "identity" to apply no encoding. + content_encoding: ("gzip"|"identity")? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/content_encoding. +//documentation +//> HTTP Content-Encoding for write request body. +//> +//> Can be set to "gzip" to compress body or "identity" to apply no encoding. + + /// Optional file with Bearer token file content is added as an Authorization header. + bearer_token: String? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/bearer_token. +//documentation +//> Optional file with Bearer token file content is added as an Authorization header. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Optional HTTP Basic Auth Credentials. + username: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/username. +//documentation +//> Optional HTTP Basic Auth Credentials. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + password: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/password. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// HTTP Proxy support. + http_proxy_url: String? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/http_proxy_url. +//documentation +//> HTTP Proxy support. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Optional TLS Config. + tls_ca: String? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/tls_ca. +//documentation +//> Optional TLS Config. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + tls_cert: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/tls_cert. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + tls_key: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/tls_key. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Use TLS but skip chain & host verification. + insecure_skip_verify: Boolean? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/insecure_skip_verify. +//documentation +//> Use TLS but skip chain & host verification. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Amount of time allowed to complete the HTTP request. + timeout: Duration? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/timeout. +//documentation +//> Amount of time allowed to complete the HTTP request. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// List of success status codes. + success_status_codes: Listing? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/success_status_codes. +//documentation +//> List of success status codes. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Data format to consume. + /// + /// Each data format has its own unique set of configuration options, read more about them here: + /// + data_format: InputDataFormat? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/HttpInput.pkl`/data_format. +//documentation +//> Data format to consume. +//> +//> Each data format has its own unique set of configuration options, read more about them here: +//> +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/InputDataFormat.pkl`/ + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/Input.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/Input.pkl new file mode 100755 index 00000000..a8960d1c --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/Input.pkl @@ -0,0 +1,76 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Telegraf input plugins are used with the InfluxData time series platform + /// to collect metrics from the system, services, or third party APIs. + /// + /// All metrics are gathered from the inputs you enable and configure in the configuration file. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Input.pkl`/minPklVersion. + abstract module com.influxdata.telegraf.plugins.inputs.Input +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Input.pkl`/ + + extends "../Plugin.pkl" + + /// How often to gather this metric. + /// + /// Normal plugins use a single global interval, + /// but if one particular input should be run less or more often, + /// you can configure that here. + interval: Duration? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Input.pkl`/interval. +//documentation +//> How often to gather this metric. +//> +//> Normal plugins use a single global interval, +//> but if one particular input should be run less or more often, +//> you can configure that here. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Override the base name of the measurement. + /// + /// Default: name of the input + name_override: String? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Input.pkl`/name_override. +//documentation +//> Override the base name of the measurement. +//> +//> Default: name of the input +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Specifies a prefix to attach to the measurement name. + name_prefix: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Input.pkl`/name_prefix. +//documentation +//> Specifies a prefix to attach to the measurement name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Specifies a suffix to attach to the measurement name. + name_suffix: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Input.pkl`/name_suffix. +//documentation +//> Specifies a suffix to attach to the measurement name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A map of tags to apply to a specific input’s measurements. + tags: Mapping? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Input.pkl`/tags. +//documentation +//> A map of tags to apply to a specific input’s measurements. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/Jolokia2AgentInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/Jolokia2AgentInput.pkl new file mode 100755 index 00000000..73124686 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/Jolokia2AgentInput.pkl @@ -0,0 +1,174 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// [Jolokia Agent Input Plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/jolokia2_agent) + /// + /// Reads JMX metrics from one or more Jolokia agent REST endpoints. + /// See [docs](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/jolokia2_agent/README.md) for examples. + module com.influxdata.telegraf.plugins.inputs.Jolokia2AgentInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/ + + extends "Input.pkl" + + /// List of endpoints to read JMX metrics from a Jolokia REST agent. + urls: Listing(length > 0) +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/urls. +//documentation +//> List of endpoints to read JMX metrics from a Jolokia REST agent. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#length. + + username: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/username. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + password: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/password. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Origin URL to include as a header in the request. + origin: String? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/origin. +//documentation +//> Origin URL to include as a header in the request. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + response_timeout: Duration? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/response_timeout. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + tls_ca: String? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/tls_ca. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + tls_cert: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/tls_cert. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + tls_key: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/tls_key. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + insecure_skip_verify: Boolean? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/insecure_skip_verify. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// String to prepend to the field names produced by all metric declarations. + default_field_prefix: String? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/default_field_prefix. +//documentation +//> String to prepend to the field names produced by all metric declarations. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Character to use to join Mbean attributes when creating fields. + default_field_separator: String? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/default_field_separator. +//documentation +//> Character to use to join Mbean attributes when creating fields. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// String to prepend to the tag names produced by all metric declarations + default_tag_prefix: String? +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/default_tag_prefix. +//documentation +//> String to prepend to the tag names produced by all metric declarations +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Metrics to collect from the Jolokia agent. + /// + /// Each metric declaration generates a Jolokia request to fetch telemetry from a JMX MBean. + metric: Listing +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/metric. +//documentation +//> Metrics to collect from the Jolokia agent. +//> +//> Each metric declaration generates a Jolokia request to fetch telemetry from a JMX MBean. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/MetricConfig# + + class MetricConfig { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/MetricConfig# + /// Metric name. + name: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/MetricConfig#name. +// documentation +// > Metric name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The object name of a JMX MBean. + /// + /// MBean property-key values can contain a wildcard `*`, allowing to fetch multiple MBeans with one declaration. + mbean: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/MetricConfig#mbean. +// documentation +// > The object name of a JMX MBean. +// > +// > MBean property-key values can contain a wildcard `*`, allowing to fetch multiple MBeans with one declaration. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// List of MBean attributes to read. + paths: Listing +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/MetricConfig#paths. +// documentation +// > List of MBean attributes to read. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// String to set as the name of the field produced by this metric. + /// + /// This can contain substitutions. + field_name: String? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/MetricConfig#field_name. +// documentation +// > String to set as the name of the field produced by this metric. +// > +// > This can contain substitutions. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// String to prepend to the field names produced by this metric declaration. + /// + /// This can contain substitutions. + field_prefix: String? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/MetricConfig#field_prefix. +// documentation +// > String to prepend to the field names produced by this metric declaration. +// > +// > This can contain substitutions. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Character to use to join Mbean attributes when creating fields. + field_separator: String? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/MetricConfig#field_separator. +// documentation +// > Character to use to join Mbean attributes when creating fields. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// String to prepend to the tag names produced by this metric declaration. + tag_prefix: String? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/MetricConfig#tag_prefix. +// documentation +// > String to prepend to the tag names produced by this metric declaration. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// List of MBean property-key names to convert into tags. + /// + /// The property-key name becomes the tag name, while the property-key value becomes the tag value. + tag_keys: Listing +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/Jolokia2AgentInput.pkl`/MetricConfig#tag_keys. +// documentation +// > List of MBean property-key names to convert into tags. +// > +// > The property-key name becomes the tag name, while the property-key value becomes the tag value. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/NetInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/NetInput.pkl new file mode 100755 index 00000000..eeb86c54 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/NetInput.pkl @@ -0,0 +1,64 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The [net input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/net/NET_README.md) + /// gathers metrics about network interface and protocol usage (Linux only). + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/NetInput.pkl`/minPklVersion. + module com.influxdata.telegraf.plugins.inputs.NetInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/NetInput.pkl`/ + + extends "Input.pkl" + + /// By default, telegraf gathers stats from any up interface (excluding loopback). + /// + /// Setting interfaces will tell it to gather these explicit interfaces, regardless of status. + /// When specifying an interface, glob-style patterns are also supported. + /// + /// Example: + /// ``` + /// interfaces { "eth*", "enp0s[0-1]", "lo" } + /// ``` + interfaces: Listing? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/NetInput.pkl`/interfaces. +//documentation +//> By default, telegraf gathers stats from any up interface (excluding loopback). +//> +//> Setting interfaces will tell it to gather these explicit interfaces, regardless of status. +//> When specifying an interface, glob-style patterns are also supported. +//> +//> Example: +//> ``` +//> interfaces { "eth*", "enp0s`0-1`", "lo" } +//> ``` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// On linux systems telegraf also collects protocol stats. + /// + /// Setting this property to `true` will skip reporting of protocol metrics. + /// + /// Default: `false` + ignore_protocol_stats: Boolean? +//^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/NetInput.pkl`/ignore_protocol_stats. +//documentation +//> On linux systems telegraf also collects protocol stats. +//> +//> Setting this property to `true` will skip reporting of protocol metrics. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/OpenTelemetry.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/OpenTelemetry.pkl new file mode 100755 index 00000000..d84be93a --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/OpenTelemetry.pkl @@ -0,0 +1,86 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// This [OpenTelemetry input plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/opentelemetry) + /// receives traces, metrics and logs from OpenTelemetry clients and agents via gRPC. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/OpenTelemetry.pkl`/minPklVersion. + module com.influxdata.telegraf.plugins.inputs.OpenTelemetry +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/OpenTelemetry.pkl`/ + + extends "Input.pkl" + + /// Address and port to listen on. + /// + /// Default if unset: `0.0.0.0:4317` + service_address: String? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/OpenTelemetry.pkl`/service_address. +//documentation +//> Address and port to listen on. +//> +//> Default if unset: `0.0.0.0:4317` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// New connection timeout + /// + /// Default if unset: 5s + timeout: Duration? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/OpenTelemetry.pkl`/timeout. +//documentation +//> New connection timeout +//> +//> Default if unset: 5s +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Supports: "prometheus-v1", "prometheus-v2" + /// + /// Default: "prometheus-v1" + metrics_schema: (*"prometheus-v1"|"prometheus-v2")? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/OpenTelemetry.pkl`/metrics_schema. +//documentation +//> Supports: "prometheus-v1", "prometheus-v2" +//> +//> Default: "prometheus-v1" + + /// Optional TLS Config. + /// + /// Set one or more allowed client CA certificate file names to + /// enable mutually authenticated TLS connections + tls_allowed_cacerts: Listing? +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/OpenTelemetry.pkl`/tls_allowed_cacerts. +//documentation +//> Optional TLS Config. +//> +//> Set one or more allowed client CA certificate file names to +//> enable mutually authenticated TLS connections +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Add service certificate + tls_cert: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/OpenTelemetry.pkl`/tls_cert. +//documentation +//> Add service certificate +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Add service key + tls_key: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/OpenTelemetry.pkl`/tls_key. +//documentation +//> Add service key +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/PrometheusInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/PrometheusInput.pkl new file mode 100755 index 00000000..58be8eb7 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/PrometheusInput.pkl @@ -0,0 +1,225 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The [prometheus input plugin](https://github.com/influxdata/telegraf/blob/release-1.17/plugins/inputs/prometheus/README.md) + /// gathers metrics from HTTP servers exposing metrics in Prometheus format. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/minPklVersion. + module com.influxdata.telegraf.plugins.inputs.PrometheusInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/ + + extends "Input.pkl" + + /// An array of urls to scrape metrics from. + urls: Listing +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/urls. +//documentation +//> An array of urls to scrape metrics from. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Tag name for the scrapped url. + /// + /// Optional, default is "url". + url_tag: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/url_tag. +//documentation +//> Tag name for the scrapped url. +//> +//> Optional, default is "url". +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Metric version controls the mapping from Prometheus metrics into Telegraf metrics. + /// + /// When using the prometheus_client output, + /// use the same value in both plugins to ensure metrics are round-tripped without modification. + /// + /// Examples: + /// ``` + /// metric_version = 1 // deprecated in 1.13 + /// metric_version = 2 // recommended version + /// ``` + metric_version: Int(isBetween(1, 2))? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/metric_version. +//documentation +//> Metric version controls the mapping from Prometheus metrics into Telegraf metrics. +//> +//> When using the prometheus_client output, +//> use the same value in both plugins to ensure metrics are round-tripped without modification. +//> +//> Examples: +//> ``` +//> metric_version = 1 // deprecated in 1.13 +//> metric_version = 2 // recommended version +//> ``` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + + /// An array of Kubernetes services to scrape metrics from. + kubernetes_services: Listing? +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/kubernetes_services. +//documentation +//> An array of Kubernetes services to scrape metrics from. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Kubernetes config file to create client from. + kube_config: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/kube_config. +//documentation +//> Kubernetes config file to create client from. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Scrape Kubernetes pods for the following prometheus annotations: + /// + /// - prometheus.io/scrape: Enable scraping for this pod. + /// - prometheus.io/scheme: If the metrics endpoint is secured + /// then you will need to set this to `https` and most likely set the tls config. + /// - prometheus.io/path: If the metrics path is not /metrics, define it with this annotation. + /// - prometheus.io/port: If port is not 9102 use this annotation. + monitor_kubernetes_pods: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/monitor_kubernetes_pods. +//documentation +//> Scrape Kubernetes pods for the following prometheus annotations: +//> +//> - prometheus.io/scrape: Enable scraping for this pod. +//> - prometheus.io/scheme: If the metrics endpoint is secured +//> then you will need to set this to `https` and most likely set the tls config. +//> - prometheus.io/path: If the metrics path is not /metrics, define it with this annotation. +//> - prometheus.io/port: If port is not 9102 use this annotation. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Get the list of pods to scrape given the following scope. + /// + /// Possible values: + /// - `cluster`: the kubernetes watch api (default, no need to specify) + /// - `node`: the local cadvisor api; for scalability. Note that the config [node_ip] or the + /// environment variable `NODE_IP` must be set to the host IP. + pod_scrape_scope: ("cluster"|"node")? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/pod_scrape_scope. +//documentation +//> Get the list of pods to scrape given the following scope. +//> +//> Possible values: +//> - `cluster`: the kubernetes watch api (default, no need to specify) +//> - `node`: the local cadvisor api; for scalability. Note that the config [`node_ip`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/inputs/PrometheusInput.pkl#L69,C1) or the +//> environment variable `NODE_IP` must be set to the host IP. + + /// Only for node scrape scope: node IP of the node that telegraf is running on. + /// + /// Either this config or the environment variable `NODE_IP` must be set. + node_ip: String(pod_scrape_scope == "node")? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/node_ip. +//documentation +//> Only for node scrape scope: node IP of the node that telegraf is running on. +//> +//> Either this config or the environment variable `NODE_IP` must be set. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/pod_scrape_scope. + + /// Restricts Kubernetes monitoring to a single namespace + /// + /// Example: `monitor_kubernetes_pods_namespace = "default"` + monitor_kubernetes_pods_namespace: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/monitor_kubernetes_pods_namespace. +//documentation +//> Restricts Kubernetes monitoring to a single namespace +//> +//> Example: `monitor_kubernetes_pods_namespace = "default"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Label selector to target pods which have the label. + /// + /// Field selector to target pods, e.g., to scrape pods on a specific node: + /// `kubernetes_field_selector = "env=dev,app=nginx"` + kubernetes_field_selector: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/kubernetes_field_selector. +//documentation +//> Label selector to target pods which have the label. +//> +//> Field selector to target pods, e.g., to scrape pods on a specific node: +//> `kubernetes_field_selector = "env=dev,app=nginx"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Use bearer token for authorization ([bearer_token] takes priority). + /// + /// Path to the bearer token file. + bearer_token: String? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/bearer_token. +//documentation +//> Use bearer token for authorization ([`bearer_token`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/inputs/PrometheusInput.pkl#L85,C1) takes priority). +//> +//> Path to the bearer token file. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Use bearer token for authorization ([bearer_token] takes priority). + bearer_token_string: String? +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/bearer_token_string. +//documentation +//> Use bearer token for authorization ([`bearer_token`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/inputs/PrometheusInput.pkl#L85,C1) takes priority). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// HTTP Basic Authentication username and password ([bearer_token] and + /// [bearer_token_string] take priority). + username: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/username. +//documentation +//> HTTP Basic Authentication username and password ([`bearer_token`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/inputs/PrometheusInput.pkl#L85,C1) and +//> [`bearer_token_string`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/inputs/PrometheusInput.pkl#L88,C1) take priority). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + password: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/password. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Specify timeout duration for slower prometheus clients. + /// + /// Default: `3.s` + response_timeout: Duration? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/response_timeout. +//documentation +//> Specify timeout duration for slower prometheus clients. +//> +//> Default: `3.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Optional TLS CA. + tls_ca: String? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/tls_ca. +//documentation +//> Optional TLS CA. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Optional TLS certificate. + tls_cert: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/tls_cert. +//documentation +//> Optional TLS certificate. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Optional TLS private key. + tls_key: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/tls_key. +//documentation +//> Optional TLS private key. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Use TLS but skip chain & host verification. + insecure_skip_verify: Boolean? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/PrometheusInput.pkl`/insecure_skip_verify. +//documentation +//> Use TLS but skip chain & host verification. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/SocketListenerInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/SocketListenerInput.pkl new file mode 100755 index 00000000..4af83467 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/SocketListenerInput.pkl @@ -0,0 +1,211 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The Socket Listener is a service input plugin that listens for messages + /// from streaming (tcp, unix) or datagram (udp, unixgram) protocols. + /// + /// The plugin expects messages in the + /// [Telegraf Input Data Formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md). + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/minPklVersion. + open module com.influxdata.telegraf.plugins.inputs.SocketListenerInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/ + + extends "Input.pkl" + + import "../parsers/InputDataFormat.pkl" + + /// URL to listen on. + /// + /// Examples: + /// ``` + /// service_address = "tcp://:8094" + /// service_address = "tcp://127.0.0.1:http" + /// service_address = "tcp4://:8094" + /// service_address = "tcp6://:8094" + /// service_address = "tcp6://[2001:db8::1]:8094" + /// service_address = "udp://:8094" + /// service_address = "udp4://:8094" + /// service_address = "udp6://:8094" + /// service_address = "unix:///tmp/telegraf.sock" + /// service_address = "unixgram:///tmp/telegraf.sock" + /// ``` + service_address: Uri +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/service_address. +//documentation +//> URL to listen on. +//> +//> Examples: +//> ``` +//> service_address = "tcp://:8094" +//> service_address = "tcp://127.0.0.1:http" +//> service_address = "tcp4://:8094" +//> service_address = "tcp6://:8094" +//> service_address = "tcp6://`2001:db8::1`:8094" +//> service_address = "udp://:8094" +//> service_address = "udp4://:8094" +//> service_address = "udp6://:8094" +//> service_address = "unix:///tmp/telegraf.sock" +//> service_address = "unixgram:///tmp/telegraf.sock" +//> ``` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + + /// Change the file mode bits on unix sockets. + /// + /// These permissions may not be respected by some platforms. + /// To safely restrict write permissions, it is best to place the socket + /// into a directory that has previously been created with the desired permissions. + /// + /// Example: + /// ``` + /// socket_mode = "777" + /// ``` + socket_mode: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/socket_mode. +//documentation +//> Change the file mode bits on unix sockets. +//> +//> These permissions may not be respected by some platforms. +//> To safely restrict write permissions, it is best to place the socket +//> into a directory that has previously been created with the desired permissions. +//> +//> Example: +//> ``` +//> socket_mode = "777" +//> ``` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Maximum number of concurrent connections. + /// + /// Only applies to stream sockets (e.g. TCP). + /// 0 (default) is unlimited. + /// + /// Default: `1024` + max_connections: UInt16? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/max_connections. +//documentation +//> Maximum number of concurrent connections. +//> +//> Only applies to stream sockets (e.g. TCP). +//> 0 (default) is unlimited. +//> +//> Default: `1024` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt16# + + /// Read timeout. + /// Only applies to stream sockets (e.g. TCP). + /// 0 (default) is unlimited. + /// + /// Default: `30.s` + read_timeout: Duration? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/read_timeout. +//documentation +//> Read timeout. +//> Only applies to stream sockets (e.g. TCP). +//> 0 (default) is unlimited. +//> +//> Default: `30.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Optional TLS configuration. + /// + /// Only applies to stream sockets (e.g. TCP). + tls_cert: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/tls_cert. +//documentation +//> Optional TLS configuration. +//> +//> Only applies to stream sockets (e.g. TCP). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + tls_key: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/tls_key. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Enables client authentication if set. + /// + /// Example: + /// ``` + /// tls_allowed_cacerts { "/etc/telegraf/clientca.pem" } + /// ``` + tls_allowed_cacerts: Listing? +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/tls_allowed_cacerts. +//documentation +//> Enables client authentication if set. +//> +//> Example: +//> ``` +//> tls_allowed_cacerts { "/etc/telegraf/clientca.pem" } +//> ``` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Maximum socket buffer size (in bytes when no unit specified). + /// + /// For stream sockets, once the buffer fills up, the sender will start backing up. + /// For datagram sockets, once the buffer fills up, metrics will start dropping. + /// + /// Default: OS default + read_buffer_size: DataSize? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/read_buffer_size. +//documentation +//> Maximum socket buffer size (in bytes when no unit specified). +//> +//> For stream sockets, once the buffer fills up, the sender will start backing up. +//> For datagram sockets, once the buffer fills up, metrics will start dropping. +//> +//> Default: OS default +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Period between keep alive probes. + /// + /// Only applies to TCP sockets. + /// 0 disables keep alive probes. + /// + /// Default: OS configuration + keep_alive_period: Duration? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/keep_alive_period. +//documentation +//> Period between keep alive probes. +//> +//> Only applies to TCP sockets. +//> 0 disables keep alive probes. +//> +//> Default: OS configuration +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Data format to consume. + /// + /// Each data format has its own unique set of configuration options, read more about them here: + /// + data_format: InputDataFormat? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/data_format. +//documentation +//> Data format to consume. +//> +//> Each data format has its own unique set of configuration options, read more about them here: +//> +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/InputDataFormat.pkl`/ + + /// Content encoding for message payloads. + /// + /// Can be set to "gzip" to or "identity" to apply no encoding. + content_encoding: ("gzip"|"identity")? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SocketListenerInput.pkl`/content_encoding. +//documentation +//> Content encoding for message payloads. +//> +//> Can be set to "gzip" to or "identity" to apply no encoding. + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/SolrInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/SolrInput.pkl new file mode 100755 index 00000000..03ef1c3b --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/SolrInput.pkl @@ -0,0 +1,56 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The [Solr input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/solr/README.md) + /// collcts stats via the [MBean Request Handler](https://solr.apache.org/guide/6_6/mbean-request-handler.html). + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SolrInput.pkl`/minPklVersion. + open module com.influxdata.telegraf.plugins.inputs.SolrInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SolrInput.pkl`/ + + extends "./Input.pkl" + + /// One or more URLs of Solr servers + servers: Listing(!isEmpty) +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SolrInput.pkl`/servers. +//documentation +//> One or more URLs of Solr servers +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + + /// Optional list of one or more Solr cores + /// + /// Defaults to all + cores: Listing? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SolrInput.pkl`/cores. +//documentation +//> Optional list of one or more Solr cores +//> +//> Defaults to all +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Optional HTTP Basic Auth Credentials. + username: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SolrInput.pkl`/username. +//documentation +//> Optional HTTP Basic Auth Credentials. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + password: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/SolrInput.pkl`/password. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/TailInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/TailInput.pkl new file mode 100755 index 00000000..6646a6d3 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/TailInput.pkl @@ -0,0 +1,155 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The tail plugin "tails" a logfile and parses each log message. + /// + /// By default, the tail plugin acts like the following unix tail command: + /// + /// ``` + /// tail -F --lines=0 myfile.log + /// ``` + /// + /// - `-F` means that it will follow the _name_ of the given file, so + /// that it will be compatible with log-rotated files, and that it will retry on + /// inaccessible files. + /// - `--lines=0` means that it will start at the end of the file (unless + /// the `from_beginning` option is set). + /// + /// see http://man7.org/linux/man-pages/man1/tail.1.html for more details. + /// + /// The plugin expects messages in one of the + /// [Telegraf Input Data Formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md). + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/TailInput.pkl`/minPklVersion. + open module com.influxdata.telegraf.plugins.inputs.TailInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/TailInput.pkl`/ + + extends "Input.pkl" + + import "../parsers/InputDataFormat.pkl" + + /// File names or a pattern to tail. + /// + /// These accept standard unix glob matching rules, but with the addition of `**` as a "super asterisk": + /// + /// - `"/var/log/**.log"`: recursively find all .log files in /var/log + /// - `"/var/log/*/*.log"`: find all .log files with a parent dir in /var/log + /// - `"/var/log/apache.log"`: just tail the apache log file + /// + /// See https://github.com/gobwas/glob for more examples. + files: Listing +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/TailInput.pkl`/files. +//documentation +//> File names or a pattern to tail. +//> +//> These accept standard unix glob matching rules, but with the addition of `**` as a "super asterisk": +//> +//> - `"/var/log/**.log"`: recursively find all .log files in /var/log +//> - `"/var/log/*/*.log"`: find all .log files with a parent dir in /var/log +//> - `"/var/log/apache.log"`: just tail the apache log file +//> +//> See https://github.com/gobwas/glob for more examples. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Read file from beginning. + /// + /// Default: `false` + from_beginning: Boolean? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/TailInput.pkl`/from_beginning. +//documentation +//> Read file from beginning. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Whether file is a named pipe. + /// + /// Default: `false` + pipe: Boolean? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/TailInput.pkl`/pipe. +//documentation +//> Whether file is a named pipe. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Method used to watch for file updates. + /// + /// Default: `"inotify"` + watch_method: (*"inotify"|"poll")? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/TailInput.pkl`/watch_method. +//documentation +//> Method used to watch for file updates. +//> +//> Default: `"inotify"` + + /// Maximum lines of the file to process that have not yet be written by the output. + /// + /// For best throughput set based on the number of metrics on each line + /// and the size of the output's metric_batch_size. + max_undelivered_lines: Int(isPositive)? +//^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/TailInput.pkl`/max_undelivered_lines. +//documentation +//> Maximum lines of the file to process that have not yet be written by the output. +//> +//> For best throughput set based on the number of metrics on each line +//> and the size of the output's metric_batch_size. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isPositive. + + /// Character encoding to use when interpreting the file contents. + /// + /// Invalid characters are replaced using the unicode replacement character. + /// When set to the empty string the data is not decoded to text. + /// + /// Examples: + /// ``` + /// character_encoding = "utf-8" + /// character_encoding = "utf-16le" + /// character_encoding = "utf-16be" + /// character_encoding = "" + /// ``` + character_encoding: String? +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/TailInput.pkl`/character_encoding. +//documentation +//> Character encoding to use when interpreting the file contents. +//> +//> Invalid characters are replaced using the unicode replacement character. +//> When set to the empty string the data is not decoded to text. +//> +//> Examples: +//> ``` +//> character_encoding = "utf-8" +//> character_encoding = "utf-16le" +//> character_encoding = "utf-16be" +//> character_encoding = "" +//> ``` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Data format to consume. + /// + /// Each data format has its own unique set of configuration options, read more about them here: + /// https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md + data_format: InputDataFormat? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/TailInput.pkl`/data_format. +//documentation +//> Data format to consume. +//> +//> Each data format has its own unique set of configuration options, read more about them here: +//> https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/InputDataFormat.pkl`/ + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/X509CertInput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/X509CertInput.pkl new file mode 100755 index 00000000..daf3c5fa --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/inputs/X509CertInput.pkl @@ -0,0 +1,125 @@ + //===----------------------------------------------------------------------===// + // Copyright © 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// This plugin provides information about X509 certificate accessible via local + /// file, tcp, udp, https or smtp protocol. + /// + /// When using a UDP address as a certificate source, the server must support + /// [DTLS](https://en.wikipedia.org/wiki/Datagram_Transport_Layer_Security). + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/minPklVersion. + open module com.influxdata.telegraf.plugins.inputs.X509CertInput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/ + + extends "Input.pkl" + + /// Certificate sources, supported wildcard expands for files. + /// + /// Prefix your entry with 'file://' if you intend to use relative paths. + sources: Listing? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/sources. +//documentation +//> Certificate sources, supported wildcard expands for files. +//> +//> Prefix your entry with 'file://' if you intend to use relative paths. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Timeout for SSL connection. + /// + /// Default if unspecified: `5.s` + timeout: Duration? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/timeout. +//documentation +//> Timeout for SSL connection. +//> +//> Default if unspecified: `5.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Pass a different name into the TLS request (Server Name Indication). + /// This is synonymous with tls_server_name, and only one of the two + /// options may be specified at one time. + server_name: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/server_name. +//documentation +//> Pass a different name into the TLS request (Server Name Indication). +//> This is synonymous with tls_server_name, and only one of the two +//> options may be specified at one time. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Only output the leaf certificates and omit the root ones. + exclude_only_roots: Boolean? +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/exclude_only_roots. +//documentation +//> Only output the leaf certificates and omit the root ones. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Pad certificate serial number with zeroes to 128-bits. + pad_serial_with_zeroes: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/pad_serial_with_zeroes. +//documentation +//> Pad certificate serial number with zeroes to 128-bits. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Password to be used with PKCS#12 or JKS files + password: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/password. +//documentation +//> Password to be used with PKCS#12 or JKS files +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// TLS CA certs + tls_ca: String? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/tls_ca. +//documentation +//> TLS CA certs +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// TLS certificate + tls_cert: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/tls_cert. +//documentation +//> TLS certificate +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// TLS key + tls_key: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/tls_key. +//documentation +//> TLS key +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// TLS server name + tls_server_name: String? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/tls_server_name. +//documentation +//> TLS server name +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Whether to connect over a proxy + use_proxy: Boolean? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/use_proxy. +//documentation +//> Whether to connect over a proxy +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The proxy URL to connect to + proxy_url: Uri? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/inputs/X509CertInput.pkl`/proxy_url. +//documentation +//> The proxy URL to connect to +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/DiscardOutput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/DiscardOutput.pkl new file mode 100755 index 00000000..5f12b0e4 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/DiscardOutput.pkl @@ -0,0 +1,26 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The Discard output plugin simply drops all metrics that are sent to it. + /// + /// It is only meant to be used for testing purposes. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/DiscardOutput.pkl`/minPklVersion. + module com.influxdata.telegraf.plugins.outputs.DiscardOutput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/DiscardOutput.pkl`/ + + extends "Output.pkl" + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/FileOutput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/FileOutput.pkl new file mode 100755 index 00000000..445b701a --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/FileOutput.pkl @@ -0,0 +1,98 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// This plugin writes telegraf metrics to files. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/FileOutput.pkl`/minPklVersion. + open module com.influxdata.telegraf.plugins.outputs.FileOutput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/FileOutput.pkl`/ + + extends "Output.pkl" + + import ".../serializers/OutputDataFormat.pkl" + + files: Listing? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/FileOutput.pkl`/files. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Use batch serialization format instead of line based delimiting. + /// + /// The batch format allows for the production of non line based output formats + /// and may more efficiently encode and write metrics. + /// + /// Defaults to false. + use_batch_format: Boolean? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/FileOutput.pkl`/use_batch_format. +//documentation +//> Use batch serialization format instead of line based delimiting. +//> +//> The batch format allows for the production of non line based output formats +//> and may more efficiently encode and write metrics. +//> +//> Defaults to false. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The file will be rotated after the time interval specified. + /// + /// When set to 0 no time based rotation is performed. + /// + /// Defaults to no rotation + rotation_interval: Duration? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/FileOutput.pkl`/rotation_interval. +//documentation +//> The file will be rotated after the time interval specified. +//> +//> When set to 0 no time based rotation is performed. +//> +//> Defaults to no rotation +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// The logfile will be rotated when it becomes larger than the specified size. + /// + /// When set to 0, no size based rotation is performed. + rotation_max_size: DataSize? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/FileOutput.pkl`/rotation_max_size. +//documentation +//> The logfile will be rotated when it becomes larger than the specified size. +//> +//> When set to 0, no size based rotation is performed. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Maximum number of rotated archives to keep, any older logs are deleted. + /// + /// If set to -1, no archives are removed. + rotation_max_archives: Int? +//^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/FileOutput.pkl`/rotation_max_archives. +//documentation +//> Maximum number of rotated archives to keep, any older logs are deleted. +//> +//> If set to -1, no archives are removed. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// The [data format](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md) + /// to output. + /// + /// Each data format has its own unique set of configuration options. + data_format: OutputDataFormat +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/FileOutput.pkl`/data_format. +//documentation +//> The [data format](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md) +//> to output. +//> +//> Each data format has its own unique set of configuration options. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/serializers/OutputDataFormat.pkl`/ + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/OpenTelemetryOutput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/OpenTelemetryOutput.pkl new file mode 100755 index 00000000..4f66ce66 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/OpenTelemetryOutput.pkl @@ -0,0 +1,158 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Sends metrics to [OpenTelemetry](https://opentelemetry.io) servers and agents via gRPC. + /// + /// + @ModuleInfo { minPklVersion = "0.24.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/minPklVersion. + open module com.influxdata.telegraf.plugins.outputs.OpenTelemetryOutput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/ + + extends "Output.pkl" + + /// The endpoint to which the metrics will be sent. + /// + /// Default: `"localhost:4317"` + service_address: String? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/service_address. +//documentation +//> The endpoint to which the metrics will be sent. +//> +//> Default: `"localhost:4317"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The timeout for the connection. + /// + /// Default: `5.s` + timeout: Duration? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/timeout. +//documentation +//> The timeout for the connection. +//> +//> Default: `5.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Optional TLS Config. + /// All variables should specify full path to the file. + /// Root certificates for verifying server certificates encoded in PEM format. + tls_ca: String? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/tls_ca. +//documentation +//> Optional TLS Config. +//> All variables should specify full path to the file. +//> Root certificates for verifying server certificates encoded in PEM format. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Path to the TLS certificate for the client encoded in PEM format. + /// May contain intermediate certificates. + tls_cert: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/tls_cert. +//documentation +//> Path to the TLS certificate for the client encoded in PEM format. +//> May contain intermediate certificates. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Path to the TLS private key for the client encoded in PEM format. + tls_key: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/tls_key. +//documentation +//> Path to the TLS private key for the client encoded in PEM format. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Send the specified TLS server name via SNI. + tls_server_name: String? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/tls_server_name. +//documentation +//> Send the specified TLS server name via SNI. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Insecure option to skip TLS server cert verification. + /// + /// Warning: it is insecure to enable this option. + /// If enabled, crypto/tls accepts any certificate presented by the server and any host name in that certificate. + /// + /// Default: `false` + insecure_skip_verify: Boolean? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/insecure_skip_verify. +//documentation +//> Insecure option to skip TLS server cert verification. +//> +//> Warning: it is insecure to enable this option. +//> If enabled, crypto/tls accepts any certificate presented by the server and any host name in that certificate. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Send data to a [Coralogix](https://coralogix.com) server. + coralogix: Coralogix? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/coralogix. +//documentation +//> Send data to a [Coralogix](https://coralogix.com) server. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/Coralogix# + + /// Set the compression method used to send data. + /// + /// Default: `"none"` + compression: ("none"|"gzip")? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/compression. +//documentation +//> Set the compression method used to send data. +//> +//> Default: `"none"` + + /// Additional OpenTelemetry resource attributes + attributes: Mapping? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/attributes. +//documentation +//> Additional OpenTelemetry resource attributes +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Additional gRPC request metadata headers + headers: Mapping? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/headers. +//documentation +//> Additional gRPC request metadata headers +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + class Coralogix { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/Coralogix# + /// The private key, which can be found in Settings > Send Your Data. + private_key: String +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/Coralogix#private_key. +// documentation +// > The private key, which can be found in Settings > Send Your Data. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The application name, which will be added to metric attributes. + application: String +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/Coralogix#application. +// documentation +// > The application name, which will be added to metric attributes. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The subsystem name, which will be added to metric attributes. + subsystem: String +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/OpenTelemetryOutput.pkl`/Coralogix#subsystem. +// documentation +// > The subsystem name, which will be added to metric attributes. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/Output.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/Output.pkl new file mode 100755 index 00000000..eceda558 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/Output.pkl @@ -0,0 +1,96 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Telegraf processor plugins write metrics to various destinations + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/Output.pkl`/minPklVersion. + abstract module com.influxdata.telegraf.plugins.outputs.Output +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/Output.pkl`/ + + extends "../Plugin.pkl" + + /// Name an instance of a plugin. + alias: String? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/Output.pkl`/alias. +//documentation +//> Name an instance of a plugin. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The maximum time between flushes. + /// + /// Use this setting to override the agent `flush_interval` on a per plugin basis. + flush_interval: Duration? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/Output.pkl`/flush_interval. +//documentation +//> The maximum time between flushes. +//> +//> Use this setting to override the agent `flush_interval` on a per plugin basis. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// The amount of time to jitter the flush interval. + /// + /// Use this setting to override the agent `flush_jitter` on a per plugin basis. + flush_jitter: Duration? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/Output.pkl`/flush_jitter. +//documentation +//> The amount of time to jitter the flush interval. +//> +//> Use this setting to override the agent `flush_jitter` on a per plugin basis. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// The maximum number of metrics to send at once. + /// + /// Use this setting to override the agent `metric_batch_size` on a per plugin basis. + metric_batch_size: Number? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/Output.pkl`/metric_batch_size. +//documentation +//> The maximum number of metrics to send at once. +//> +//> Use this setting to override the agent `metric_batch_size` on a per plugin basis. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// The maximum number of unsent metrics to buffer. + /// + /// Use this setting to override the agent `metric_buffer_limit` on a per plugin basis. + metric_buffer_limit: Number? +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/Output.pkl`/metric_buffer_limit. +//documentation +//> The maximum number of unsent metrics to buffer. +//> +//> Use this setting to override the agent `metric_buffer_limit` on a per plugin basis. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// Override the original name of the measurement. + name_override: String? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/Output.pkl`/name_override. +//documentation +//> Override the original name of the measurement. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Specifies a prefix to attach to the measurement name. + name_prefix: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/Output.pkl`/name_prefix. +//documentation +//> Specifies a prefix to attach to the measurement name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Specifies a suffix to attach to the measurement name. + name_suffix: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/Output.pkl`/name_suffix. +//documentation +//> Specifies a suffix to attach to the measurement name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/PrometheusClientOutput.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/PrometheusClientOutput.pkl new file mode 100755 index 00000000..637d4a08 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/outputs/PrometheusClientOutput.pkl @@ -0,0 +1,151 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// This plugin starts a Prometheus Client, it exposes all metrics on /metrics (default) to be polled by a Prometheus server. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/minPklVersion. + open module com.influxdata.telegraf.plugins.outputs.PrometheusClientOutput +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/ + + extends "Output.pkl" + + /// Address to listen on. + listen: String? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/listen. +//documentation +//> Address to listen on. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Metric version controls the mapping from Prometheus metrics into Telegraf metrics. + /// + /// See "Metric Format Configuration" in plugins/inputs/prometheus/README.md for details. + /// Defaults to `1`. + metric_version: Int(isBetween(1,2))? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/metric_version. +//documentation +//> Metric version controls the mapping from Prometheus metrics into Telegraf metrics. +//> +//> See "Metric Format Configuration" in plugins/inputs/prometheus/README.md for details. +//> Defaults to `1`. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + + /// Username for optional basic authentication. + basic_username: String? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/basic_username. +//documentation +//> Username for optional basic authentication. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Password for optional basic authentication. + basic_password: String? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/basic_password. +//documentation +//> Password for optional basic authentication. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// If set, the IP Ranges which are allowed to access metrics. + /// + /// Defaults to no restrictions. + ip_range: Listing? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/ip_range. +//documentation +//> If set, the IP Ranges which are allowed to access metrics. +//> +//> Defaults to no restrictions. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Path to publish the metrics on. + /// + /// Defaults to `/metrics`. + path: String? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/path. +//documentation +//> Path to publish the metrics on. +//> +//> Defaults to `/metrics`. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Expiration interval for each metric. + /// + /// Set to `0` for no expiration. + /// Defaults to 60 seconds. + expiration_interval: Duration? +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/expiration_interval. +//documentation +//> Expiration interval for each metric. +//> +//> Set to `0` for no expiration. +//> Defaults to 60 seconds. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Collectors to disable, valid entries are "gocollector" and "process". + /// + /// Defaults to `gocollector' and `process' being enabled. + collectors_exclude: Listing<"gocollector"|"process">(isDistinct)? +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/collectors_exclude. +//documentation +//> Collectors to disable, valid entries are "gocollector" and "process". +//> +//> Defaults to `gocollector' and `process' being enabled. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. + + /// Send string metrics as Prometheus labels. + /// + /// Defaults to `true`. + string_as_label: Boolean? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/string_as_label. +//documentation +//> Send string metrics as Prometheus labels. +//> +//> Defaults to `true`. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Path to certificate for optional TLS. + tls_cert: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/tls_cert. +//documentation +//> Path to certificate for optional TLS. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Path to key for optional TLS. + tls_key: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/tls_key. +//documentation +//> Path to key for optional TLS. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Path to CA Certificate files to enable optional mTLS. + tls_allowed_cacerts: Listing? +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/tls_allowed_cacerts. +//documentation +//> Path to CA Certificate files to enable optional mTLS. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Export metric collection time. + /// + /// Defaults to `false`. + export_timestamp: Boolean? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/outputs/PrometheusClientOutput.pkl`/export_timestamp. +//documentation +//> Export metric collection time. +//> +//> Defaults to `false`. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/CollectdInputDataFormat.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/CollectdInputDataFormat.pkl new file mode 100755 index 00000000..9cc52f96 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/CollectdInputDataFormat.pkl @@ -0,0 +1,70 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The Collectd data format parses Collectd data into metric fields. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CollectdInputDataFormat.pkl`/minPklVersion. + module com.influxdata.telegraf.plugins.parsers.CollectdInputDataFormat +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CollectdInputDataFormat.pkl`/ + + extends "InputDataFormat.pkl" + + data_format: "collectd" +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CollectdInputDataFormat.pkl`/data_format. + + /// Authentication file for cryptographic security levels. + collectd_auth_file: String? +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CollectdInputDataFormat.pkl`/collectd_auth_file. +//documentation +//> Authentication file for cryptographic security levels. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Collectd security level to enfore. + /// + /// Default: `"none"` + collectd_security_level: ("none"|"sign"|"encrypt")? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CollectdInputDataFormat.pkl`/collectd_security_level. +//documentation +//> Collectd security level to enfore. +//> +//> Default: `"none"` + + /// Paths of to TypesDB specifications. + collectd_typesdb: Listing? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CollectdInputDataFormat.pkl`/collectd_typesdb. +//documentation +//> Paths of to TypesDB specifications. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The method for handling multi-value plugins. + /// + /// Multi-value plugins can be handled two ways: + /// * "split" will parse and store the multi-value plugin data into separate measurements. + /// * "join" will parse and store the multi-value plugin as a single multi-value measurement. + /// + /// Default: `"split"`, for backward compatibility with previous versions of influxdb. + collectd_parse_multivalue: ("split"|"join")? +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CollectdInputDataFormat.pkl`/collectd_parse_multivalue. +//documentation +//> The method for handling multi-value plugins. +//> +//> Multi-value plugins can be handled two ways: +//> * "split" will parse and store the multi-value plugin data into separate measurements. +//> * "join" will parse and store the multi-value plugin as a single multi-value measurement. +//> +//> Default: `"split"`, for backward compatibility with previous versions of influxdb. + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/CsvInputDataFormat.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/CsvInputDataFormat.pkl new file mode 100755 index 00000000..151b206f --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/CsvInputDataFormat.pkl @@ -0,0 +1,202 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The `csv` parser creates metrics from a document containing comma separated values. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/minPklVersion. + open module com.influxdata.telegraf.plugins.parsers.CsvInputDataFormat +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/ + + extends "InputDataFormat.pkl" + + files: Listing +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/files. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + data_format: "csv" +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/data_format. + + /// Indicates how many rows to treat as a header. + /// + /// By default, the parser assumes there is no header and will parse the first row as data. + /// If set to anything more than 1, column names will be concatenated with the name listed in the next header row. + /// If [csv_column_names] is specified, the column names in header will be overridden. + csv_header_row_count: Int(isPositive)? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_header_row_count. +//documentation +//> Indicates how many rows to treat as a header. +//> +//> By default, the parser assumes there is no header and will parse the first row as data. +//> If set to anything more than 1, column names will be concatenated with the name listed in the next header row. +//> If [`csv_column_names`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/parsers/CsvInputDataFormat.pkl#L38,C1) is specified, the column names in header will be overridden. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isPositive. + + /// For assigning custom names to columns. + /// + /// If this is specified, all columns should have a name. + /// Unnamed columns will be ignored by the parser. + /// If [csv_header_row_count] is set to 0, this config must be used. + csv_column_names: Listing? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_column_names. +//documentation +//> For assigning custom names to columns. +//> +//> If this is specified, all columns should have a name. +//> Unnamed columns will be ignored by the parser. +//> If [`csv_header_row_count`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/parsers/CsvInputDataFormat.pkl#L31,C1) is set to 0, this config must be used. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// For assigning explicit data types to columns. + /// + /// Specify types in order by column (e.g., `csv_column_types { "string"; "int"; "float" }`). + /// If this is not specified, type conversion will be done on the types above. + csv_column_types: Listing<"int"|"float"|"bool"|"string">? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_column_types. +//documentation +//> For assigning explicit data types to columns. +//> +//> Specify types in order by column (e.g., `csv_column_types { "string"; "int"; "float" }`). +//> If this is not specified, type conversion will be done on the types above. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + + /// Indicates the number of rows to skip before looking for header information. + csv_skip_rows: Int(isPositive)? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_skip_rows. +//documentation +//> Indicates the number of rows to skip before looking for header information. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isPositive. + + /// Indicates the number of columns to skip before looking for data to parse. + /// + /// These columns will be skipped in the header as well. + csv_skip_columns: Int(isPositive)? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_skip_columns. +//documentation +//> Indicates the number of columns to skip before looking for data to parse. +//> +//> These columns will be skipped in the header as well. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isPositive. + + /// The separator between csv fields. + /// + /// Default: `","` + csv_delimiter: String? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_delimiter. +//documentation +//> The separator between csv fields. +//> +//> Default: `","` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The character reserved for marking a row as a comment row. + /// + /// Commented rows are skipped and not parsed. + csv_comment: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_comment. +//documentation +//> The character reserved for marking a row as a comment row. +//> +//> Commented rows are skipped and not parsed. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// If set to true, the parser will remove leading whitespace from fields. + /// + /// Default: `false` + csv_trim_space: Boolean? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_trim_space. +//documentation +//> If set to true, the parser will remove leading whitespace from fields. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Columns listed here will be added as tags. + /// + /// Any other columns will be added as fields. + csv_tag_columns: Listing? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_tag_columns. +//documentation +//> Columns listed here will be added as tags. +//> +//> Any other columns will be added as fields. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The column to extract the name of the metric from. + /// + /// Will not be included as field in metric. + csv_measurement_column: String? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_measurement_column. +//documentation +//> The column to extract the name of the metric from. +//> +//> Will not be included as field in metric. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The column to extract time information for the metric. + /// + /// [csv_timestamp_format] must be specified if this is used. + /// Will not be included as field in metric. + csv_timestamp_column: String? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_timestamp_column. +//documentation +//> The column to extract time information for the metric. +//> +//> [`csv_timestamp_format`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/parsers/CsvInputDataFormat.pkl#L88,C1) must be specified if this is used. +//> Will not be included as field in metric. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The format of time data extracted from [csv_timestamp_column]. + /// + /// This must be specified if [csv_timestamp_column] is specified. + csv_timestamp_format: String? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_timestamp_format. +//documentation +//> The format of time data extracted from [`csv_timestamp_column`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/parsers/CsvInputDataFormat.pkl#L83,C1). +//> +//> This must be specified if [`csv_timestamp_column`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/parsers/CsvInputDataFormat.pkl#L83,C1) is specified. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The timezone of time data extracted from [csv_timestamp_column] + /// in case there is no timezone information. + /// + /// It follows the IANA Time Zone database. + csv_timezone: String? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_timezone. +//documentation +//> The timezone of time data extracted from [`csv_timestamp_column`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/parsers/CsvInputDataFormat.pkl#L83,C1) +//> in case there is no timezone information. +//> +//> It follows the IANA Time Zone database. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Indicates values to skip, such as an empty string value `""`. + /// + /// The field will be skipped entirely where it matches any values inserted here. + csv_skip_values: Listing? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/CsvInputDataFormat.pkl`/csv_skip_values. +//documentation +//> Indicates values to skip, such as an empty string value `""`. +//> +//> The field will be skipped entirely where it matches any values inserted here. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/InputDataFormat.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/InputDataFormat.pkl new file mode 100755 index 00000000..4f140dd8 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/InputDataFormat.pkl @@ -0,0 +1,26 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Base class for [input data formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md). + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/InputDataFormat.pkl`/minPklVersion. + abstract module com.influxdata.telegraf.plugins.parsers.InputDataFormat +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/InputDataFormat.pkl`/ + + data_format: String +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/InputDataFormat.pkl`/data_format. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/JsonInputDataFormat.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/JsonInputDataFormat.pkl new file mode 100755 index 00000000..10f92f2c --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/parsers/JsonInputDataFormat.pkl @@ -0,0 +1,154 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The JSON data format parses a JSON object or an array of objects into metric fields. + /// + /// **NOTE:** All JSON numbers are converted to float fields. + /// JSON strings and booleans are ignored unless specified in the [tag_keys] or [json_string_fields] options. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/JsonInputDataFormat.pkl`/minPklVersion. + module com.influxdata.telegraf.plugins.parsers.JsonInputDataFormat +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/JsonInputDataFormat.pkl`/ + + extends "InputDataFormat.pkl" + + data_format: "json" +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/JsonInputDataFormat.pkl`/data_format. + + /// When strict is true and a JSON array is being parsed, + /// all objects within the array must be valid. + /// + /// Default: `true` + json_strict: Boolean? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/JsonInputDataFormat.pkl`/json_strict. +//documentation +//> When strict is true and a JSON array is being parsed, +//> all objects within the array must be valid. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// A GJSON path that specifies a specific chunk of JSON to be parsed. + /// + /// If not specified, the whole document will be parsed. + /// + /// GJSON query paths are described here: + /// + json_query: String? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/JsonInputDataFormat.pkl`/json_query. +//documentation +//> A GJSON path that specifies a specific chunk of JSON to be parsed. +//> +//> If not specified, the whole document will be parsed. +//> +//> GJSON query paths are described here: +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// An array of keys that should be added as tags. + /// + /// Matching keys are no longer saved as fields. + /// Supports wildcard glob matching. + tag_keys: Listing? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/JsonInputDataFormat.pkl`/tag_keys. +//documentation +//> An array of keys that should be added as tags. +//> +//> Matching keys are no longer saved as fields. +//> Supports wildcard glob matching. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Array of glob pattern strings or booleans keys that should be added as string fields. + json_string_fields: Listing? +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/JsonInputDataFormat.pkl`/json_string_fields. +//documentation +//> Array of glob pattern strings or booleans keys that should be added as string fields. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The key to use as the measurement name. + json_name_key: String? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/JsonInputDataFormat.pkl`/json_name_key. +//documentation +//> The key to use as the measurement name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The key containing the time that should be used to create the metric. + json_time_key: String? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/JsonInputDataFormat.pkl`/json_time_key. +//documentation +//> The key containing the time that should be used to create the metric. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The time layout that should be used to interpret [json_time_key]. + /// + /// The time must be `"unix"`, `"unix_ms"`, `"unix_us"`, `"unix_ns"`, or a time in the "reference time". + /// To define a different format, arrange the values from the "reference time" + /// in the example to match the format you will be using. + /// For more information on the "reference time", visit . + /// + /// Examples: + /// ``` + /// json_time_format = "Mon Jan 2 15:04:05 -0700 MST 2006" + /// json_time_format = "2006-01-02T15:04:05Z07:00" + /// json_time_format = "01/02/2006 15:04:05" + /// json_time_format = "unix" + /// json_time_format = "unix_ms" + /// ``` + json_time_format: ("unix"|"unix_ms"|"unix_us"|"unix_ns"|String)? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/JsonInputDataFormat.pkl`/json_time_format. +//documentation +//> The time layout that should be used to interpret [`json_time_key`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/com.influxdata.telegraf/plugins/parsers/JsonInputDataFormat.pkl#L54,C1). +//> +//> The time must be `"unix"`, `"unix_ms"`, `"unix_us"`, `"unix_ns"`, or a time in the "reference time". +//> To define a different format, arrange the values from the "reference time" +//> in the example to match the format you will be using. +//> For more information on the "reference time", visit . +//> +//> Examples: +//> ``` +//> json_time_format = "Mon Jan 2 15:04:05 -0700 MST 2006" +//> json_time_format = "2006-01-02T15:04:05Z07:00" +//> json_time_format = "01/02/2006 15:04:05" +//> json_time_format = "unix" +//> json_time_format = "unix_ms" +//> ``` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Allows you to provide an override for timestamps + /// that don't already include an offset, e.g., `"04/06/2016 12:41:45"`. + /// + /// Default: `""` (renders UTC) + /// + /// Options are as follows: + /// - `"Local"`: interpret based on machine localtime + /// - `"America/New_York"`: Unix TZ values like those found in https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + /// - `"UTC"` (or blank/unspecified): will return timestamp in UTC + json_timezone: String? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/parsers/JsonInputDataFormat.pkl`/json_timezone. +//documentation +//> Allows you to provide an override for timestamps +//> that don't already include an offset, e.g., `"04/06/2016 12:41:45"`. +//> +//> Default: `""` (renders UTC) +//> +//> Options are as follows: +//> - `"Local"`: interpret based on machine localtime +//> - `"America/New_York"`: Unix TZ values like those found in https://en.wikipedia.org/wiki/List_of_tz_database_time_zones +//> - `"UTC"` (or blank/unspecified): will return timestamp in UTC +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/processors/Processor.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/processors/Processor.pkl new file mode 100755 index 00000000..5dce1841 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/processors/Processor.pkl @@ -0,0 +1,36 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Processor plugins transform, decorate, and/or filter metrics collected by input plugins, + /// passing the transformed metrics to the output plugins + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/processors/Processor.pkl`/minPklVersion. + abstract module com.influxdata.telegraf.plugins.processors.Processor +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/processors/Processor.pkl`/ + + extends "../Plugin.pkl" + + /// This is the order in which processors are executed. + /// + /// If this is not specified, then processor execution order will be random. + order: Number? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/processors/Processor.pkl`/order. +//documentation +//> This is the order in which processors are executed. +//> +//> If this is not specified, then processor execution order will be random. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/processors/StarlarkProcessor.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/processors/StarlarkProcessor.pkl new file mode 100755 index 00000000..3d3af128 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/processors/StarlarkProcessor.pkl @@ -0,0 +1,52 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The starlark processor calls a Starlark function for each matched metric, allowing for custom programmatic metric processing. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/processors/StarlarkProcessor.pkl`/minPklVersion. + open module com.influxdata.telegraf.plugins.processors.StarlarkProcessor +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/processors/StarlarkProcessor.pkl`/ + + extends "Processor.pkl" + + /// Source of the Starlark script. + @SourceCode { language = "Starlark" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/processors/StarlarkProcessor.pkl`/language. + source: String? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/processors/StarlarkProcessor.pkl`/source. +//documentation +//> Source of the Starlark script. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// File containing a Starlark script. + script: String? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/processors/StarlarkProcessor.pkl`/script. +//documentation +//> File containing a Starlark script. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The constants of the Starlark script. + constants: Mapping? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/processors/StarlarkProcessor.pkl`/constants. +//documentation +//> The constants of the Starlark script. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/serializers/JsonOutputDataFormat.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/serializers/JsonOutputDataFormat.pkl new file mode 100755 index 00000000..dcd70192 --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/serializers/JsonOutputDataFormat.pkl @@ -0,0 +1,51 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The [JSON output data format](https://docs.influxdata.com/telegraf/v1.17/data_formats/output/json/) + /// serializes Telegraf metrics into JSON documents. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/serializers/JsonOutputDataFormat.pkl`/minPklVersion. + module com.influxdata.telegraf.plugins.serializers.JsonOutputDataFormat +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/serializers/JsonOutputDataFormat.pkl`/ + + extends "OutputDataFormat.pkl" + + data_format: "json" +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/serializers/JsonOutputDataFormat.pkl`/data_format. + + /// Files to write to. + /// + /// `"stdout"` is a specially handled file. + files: Listing +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/serializers/JsonOutputDataFormat.pkl`/files. +//documentation +//> Files to write to. +//> +//> `"stdout"` is a specially handled file. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The resolution to use for the metric timestamp. + /// + /// Durations are truncated to the power of 10 less than the specified units. + json_timestamp_units: Duration +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/serializers/JsonOutputDataFormat.pkl`/json_timestamp_units. +//documentation +//> The resolution to use for the metric timestamp. +//> +//> Durations are truncated to the power of 10 less than the specified units. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/serializers/OutputDataFormat.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/serializers/OutputDataFormat.pkl new file mode 100755 index 00000000..4fc1175c --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/plugins/serializers/OutputDataFormat.pkl @@ -0,0 +1,26 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Base class for [output data formats](https://docs.influxdata.com/telegraf/v1.17/data_formats/output/). + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/serializers/OutputDataFormat.pkl`/minPklVersion. + abstract module com.influxdata.telegraf.plugins.serializers.OutputDataFormat +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/serializers/OutputDataFormat.pkl`/ + + data_format: String +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `plugins/serializers/OutputDataFormat.pkl`/data_format. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + diff --git a/pkl-pantrysnapshot/com.influxdata.telegraf/tests/Telegraf.pkl b/pkl-pantrysnapshot/com.influxdata.telegraf/tests/Telegraf.pkl new file mode 100755 index 00000000..74ff344b --- /dev/null +++ b/pkl-pantrysnapshot/com.influxdata.telegraf/tests/Telegraf.pkl @@ -0,0 +1,43 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module com.influxdata.telegraf.tests.Telegraf +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `tests/Telegraf.pkl`/ + + amends "pkl:test" + + local allExamples = import*("../examples/*.pkl") +// ^^^^^^^^^^^ definition local allExamples_20 + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/com.influxdata.telegraf 1.5.0 `tests/Telegraf.pkl`/examples. + for (name in allExamples.keys) { +// ^^^^ definition local name_23 +// ^^^^^^^^^^^ reference local allExamples_20 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#keys. + [name.drop("../examples".length + 1).replaceLast("pkl", "toml")] { +// ^^^^ reference local name_23 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceLast(). + allExamples[name].output.text +// ^^^^^^^^^^^ reference local allExamples_20 +// ^^^^ reference local name_23 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + } + diff --git a/pkl-pantrysnapshot/icalendar/PklProject b/pkl-pantrysnapshot/icalendar/PklProject new file mode 100755 index 00000000..f9902f44 --- /dev/null +++ b/pkl-pantrysnapshot/icalendar/PklProject @@ -0,0 +1,26 @@ + //===----------------------------------------------------------------------===// + // Copyright © 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Library for working with iCalendar data. + /// + /// Implements [RFC 5545](https://datatracker.ietf.org/doc/html/rfc5545). + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 PklProject/package. + version = "0.1.1" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/icalendar/tests/Recur.pkl b/pkl-pantrysnapshot/icalendar/tests/Recur.pkl new file mode 100755 index 00000000..fc29d121 --- /dev/null +++ b/pkl-pantrysnapshot/icalendar/tests/Recur.pkl @@ -0,0 +1,386 @@ + //===----------------------------------------------------------------------===// + // Copyright © 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module icalendar.tests.Recur +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/ + amends "pkl:test" + + import "../type/Recur.pkl" + import "../type/Date.pkl" + import "../type/DateTime.pkl" + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/facts. + ["with date"] { + new Recur { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = Date.Date("20000101") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + interval = 1 +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/interval. + until = Date.Date("20250101") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/until. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). + byday { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byday. + "MO" + new { weeknum = -1; weekday = "FR" } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/weeknum. +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/weekday. + } + bymonthday { 15; -15 } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bymonthday. + byyearday { 100; -100 } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byyearday. + bymonth { 1; 11 } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bymonth. + wkst = "MO" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/wkst. + bysetpos { -1; 1 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bysetpos. + }.toString() == """ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + DTSTART;VALUE=DATE:20000101 + RRULE:FREQ=YEARLY;INTERVAL=1;UNTIL=20250101;BYDAY=MO,-1FR;BYMONTHDAY=15,-15;BYYEARDAY=100,-100;BYMONTH=1,11;WKST=MO;BYSETPOS=-1,1 + """ + + // tzid not allowed for dates, only datetimes + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = Date.Date("20000101") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). + tzid = "America/Los_Angeles" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/tzid. + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + tzid = "America/Los_Angeles" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/tzid. + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + until = Date.Date("20250101") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/until. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + + // until type must be date if dtstart is date + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = Date.Date("20000101") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + until = DateTime.DateTime("20250101T000000") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/until. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + + // until and count forbidden together + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = Date.Date("20000101") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + count = 25 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/count. + until = Date.Date("20250101") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/until. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + + // bysecond cannot be used with date dtstart + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = Date.Date("20000101") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + bysecond { 0 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bysecond. + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + + // byminute cannot be used with date dtstart + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = Date.Date("20000101") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + byminute { 0 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byminute. + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + + // byhour cannot be used with date dtstart + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = Date.Date("20000101") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + byhour { 0 } +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byhour. + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + + // bysetpos cannot be used without another by* property + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = Date.Date("20000101") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + bysetpos { 1 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bysetpos. + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + } + + ["with datetime"] { + // utc + new Recur { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = DateTime.DateTime("20000101T000000Z") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + interval = 1 +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/interval. + until = DateTime.DateTime("20250101T000000Z") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/until. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + bysecond { 0; 30 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bysecond. + byminute { 0; 30 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byminute. + byhour { 0; 12 } +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byhour. + byday { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byday. + "MO" + new { weeknum = -1; weekday = "FR" } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/weeknum. +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/weekday. + } + bymonthday { 15; -15 } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bymonthday. + byyearday { 100; -100 } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byyearday. + bymonth { 1; 11 } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bymonth. + wkst = "MO" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/wkst. + bysetpos { -1; 1 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bysetpos. + }.toString() == """ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + DTSTART:20000101T000000Z + RRULE:FREQ=YEARLY;INTERVAL=1;UNTIL=20250101T000000Z;BYSECOND=0,30;BYMINUTE=0,30;BYHOUR=0,12;BYDAY=MO,-1FR;BYMONTHDAY=15,-15;BYYEARDAY=100,-100;BYMONTH=1,11;WKST=MO;BYSETPOS=-1,1 + """ + + // floating + new Recur { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = DateTime.DateTime("20000101T000000") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + interval = 1 +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/interval. + until = DateTime.DateTime("20250101T000000") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/until. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + bysecond { 0; 30 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bysecond. + byminute { 0; 30 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byminute. + byhour { 0; 12 } +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byhour. + byday { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byday. + "MO" + new { weeknum = -1; weekday = "FR" } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/weeknum. +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/weekday. + } + bymonthday { 15; -15 } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bymonthday. + byyearday { 100; -100 } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byyearday. + bymonth { 1; 11 } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bymonth. + wkst = "MO" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/wkst. + bysetpos { -1; 1 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bysetpos. + }.toString() == """ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + DTSTART:20000101T000000 + RRULE:FREQ=YEARLY;INTERVAL=1;UNTIL=20250101T000000;BYSECOND=0,30;BYMINUTE=0,30;BYHOUR=0,12;BYDAY=MO,-1FR;BYMONTHDAY=15,-15;BYYEARDAY=100,-100;BYMONTH=1,11;WKST=MO;BYSETPOS=-1,1 + """ + + // with timezone + new Recur { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = DateTime.DateTime("20000101T000000") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + tzid = "America/Los_Angeles" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/tzid. + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + interval = 1 +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/interval. + until = DateTime.DateTime("20250101T000000") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/until. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + bysecond { 0; 30 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bysecond. + byminute { 0; 30 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byminute. + byhour { 0; 12 } +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byhour. + byday { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byday. + "MO" + new { weeknum = -1; weekday = "FR" } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/weeknum. +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/weekday. + } + bymonthday { 15; -15 } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bymonthday. + byyearday { 100; -100 } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/byyearday. + bymonth { 1; 11 } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bymonth. + wkst = "MO" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/wkst. + bysetpos { -1; 1 } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/bysetpos. + }.toString() == """ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + DTSTART;TZID=America/Los_Angeles:20000101T000000 + RRULE:FREQ=YEARLY;INTERVAL=1;UNTIL=20250101T000000;BYSECOND=0,30;BYMINUTE=0,30;BYHOUR=0,12;BYDAY=MO,-1FR;BYMONTHDAY=15,-15;BYYEARDAY=100,-100;BYMONTH=1,11;WKST=MO;BYSETPOS=-1,1 + """ + + // forbid utc until with non-utc dtstart + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = DateTime.DateTime("20000101T000000") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + until = DateTime.DateTime("20250101T000000Z") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/until. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + // forbid utc dtstart with non-utc until + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = DateTime.DateTime("20000101T000000Z") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + until = DateTime.DateTime("20250101T000000") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/until. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + // forbid utc dtstart with tzid + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + dtstart = DateTime.DateTime("20000101T000000Z") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/dtstart. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + tzid = "America/Los_Angeles" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/tzid. + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + // forbid utc until with tzid + module.catchOrNull(() -> new Recur { +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + tzid = "America/Los_Angeles" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/tzid. + freq = "YEARLY" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/freq. + until = DateTime.DateTime("20250101T000000Z") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `tests/Recur.pkl`/until. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). + }.toString()) != null +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). + } + } + diff --git a/pkl-pantrysnapshot/icalendar/type/Date.pkl b/pkl-pantrysnapshot/icalendar/type/Date.pkl new file mode 100755 index 00000000..473fd96e --- /dev/null +++ b/pkl-pantrysnapshot/icalendar/type/Date.pkl @@ -0,0 +1,92 @@ + //===----------------------------------------------------------------------===// + // Copyright © 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// This value type is used to identify values that contain a calendar date. + /// + /// https://datatracker.ietf.org/doc/html/rfc5545#section-3.3.4 + module icalendar.type.Date +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ + + import "Date.pkl" + + // language=Regexp + const hidden dateRegex = "([0-9]{4})(0[1-9]|1[12])(0[1-9]|[12][0-9]|3[01])" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/dateRegex. + typealias DateString = String(matches(Regex(dateRegex))) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/DateString# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/dateRegex. + + /// Year value. + y: Int(isBetween(0, 9999)) +//^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/y. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + + /// Month value. + m: Int(isBetween(1, 12)) +//^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/m. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + + /// Day value. + d: Int(isBetween(1, 31)) +//^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/d. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + + function toString(): String = List( +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/toString(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + y.toString().padStart(4, "0"), +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/y. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + m.toString().padStart(2, "0"), +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/m. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + d.toString().padStart(2, "0") +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/d. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + ).join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + const function Date(input: DateString): Date = new { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). +// ^^^^^ definition local input_42 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/DateString# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ + y = input.substring(0, 4).toInt() +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/y. +// ^^^^^ reference local input_42 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + m = input.substring(4, 6).toInt() +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/m. +// ^^^^^ reference local input_42 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + d = input.substring(6, 8).toInt() +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/d. +// ^^^^^ reference local input_42 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + } + diff --git a/pkl-pantrysnapshot/icalendar/type/DateTime.pkl b/pkl-pantrysnapshot/icalendar/type/DateTime.pkl new file mode 100755 index 00000000..2d0c3ed9 --- /dev/null +++ b/pkl-pantrysnapshot/icalendar/type/DateTime.pkl @@ -0,0 +1,87 @@ + //===----------------------------------------------------------------------===// + // Copyright © 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// This value type is used to identify values that specify a precise calendar date and time of day. + /// + /// https://datatracker.ietf.org/doc/html/rfc5545#section-3.3.5 + module icalendar.type.DateTime +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ + + import "Date.pkl" + import "Time.pkl" + import "DateTime.pkl" + + typealias DateTimeString = String(matches(Regex("\(Date.dateRegex)T\(Time.timeRegex)"))) +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTimeString# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/dateRegex. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/timeRegex. + + date: Date +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/date. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ + + time: Time +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/time. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/ + + /// Indicates that [time] is UTC, not local. + fixed utc: Boolean = time.utc +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/utc. +// documentation +// > Indicates that [`time`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/icalendar/type/DateTime.pkl#L29,C1) is UTC, not local. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/time. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/utc. + + function toString(): String = "\(date)T\(time)" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/toString(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/date. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/time. + + /// Parse a [DateTimeString] into a [DateTime]. + const function DateTime(input: DateTimeString): DateTime = new { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTime(). +// documentation +// > Parse a [`DateTimeString`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/icalendar/type/DateTime.pkl#L25,C11) into a [`DateTime`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/icalendar/type/DateTime.pkl#L19,C1). +// ^^^^^ definition local input_37 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/DateTimeString# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ + local parts: List(length == 2) = input.split("T") +// ^^^^^ definition local parts_38 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^ reference local input_37 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). + date = Date.Date(parts.first) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/date. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/Date(). +// ^^^^^ reference local parts_38 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. + time = Time.Time(parts.last) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/time. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/Time(). +// ^^^^^ reference local parts_38 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + } + diff --git a/pkl-pantrysnapshot/icalendar/type/Recur.pkl b/pkl-pantrysnapshot/icalendar/type/Recur.pkl new file mode 100755 index 00000000..d1639c44 --- /dev/null +++ b/pkl-pantrysnapshot/icalendar/type/Recur.pkl @@ -0,0 +1,456 @@ + //===----------------------------------------------------------------------===// + // Copyright © 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A recurrence rule. + /// + /// https://datatracker.ietf.org/doc/html/rfc5545#section-3.3.10 + module icalendar.type.Recur +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/ + + import "Date.pkl" + import "DateTime.pkl" + + typealias Frequency = "SECONDLY"|"MINUTELY"|"HOURLY"|"DAILY"|"WEEKLY"|"MONTHLY"|"YEARLY" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Frequency# + + typealias WeekdayString = "SU"|"MO"|"TU"|"WE"|"TH"|"FR"|"SA" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/WeekdayString# + + class Weekday { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Weekday# + weekday: WeekdayString +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Weekday#weekday. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/WeekdayString# + weeknum: Int(this != 0)? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Weekday#weeknum. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + function toString(): String = List( +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Weekday#toString(). +// documentation +// > Returns a string representation of `this`. +// > +// > This method is used to convert the values of string interpolation expressions to strings. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + weeknum?.ifNonNull((n) -> if (n as Int > 0) "+" else ""), +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Weekday#weeknum. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^ definition local n_33 +// ^ reference local n_33 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + weeknum?.toString(), +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Weekday#weeknum. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + weekday +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Weekday#weekday. + ).filterNonNull().join("") +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + + dtstart: ( +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/dtstart. + * DateTime(utc.implies(tzid == null)) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/utc. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/tzid. + |Date(tzid == null) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/tzid. + )? + + tzid: String? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/tzid. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The FREQ rule part identifies the type of recurrence rule. + freq: Frequency +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/freq. +//documentation +//> The FREQ rule part identifies the type of recurrence rule. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Frequency# + + /// The INTERVAL rule part contains a positive integer representing at which intervals the recurrence rule repeats. + /// + /// Defaults to 1 if not specified. + interval: Int(this > 0)? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/interval. +//documentation +//> The INTERVAL rule part contains a positive integer representing at which intervals the recurrence rule repeats. +//> +//> Defaults to 1 if not specified. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// The UNTIL rule part defines a DATE or DATE-TIME value that bounds the recurrence rule in an inclusive manner. + /// + /// If the value specified by UNTIL is synchronized with the specified recurrence, this DATE or DATE-TIME becomes the last instance of the recurrence. + /// If the "DTSTART" property is specified as a date with local time, then the UNTIL rule part MUST also be specified as a date with local time. + /// If the "DTSTART" property is specified as a date with UTC time or a date with local time and time zone reference, then the UNTIL rule part MUST be specified as a date with UTC time. + /// If not present, and the COUNT rule part is also not present, the "RRULE" is considered to repeat forever. + until: ( +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/until. +//documentation +//> The UNTIL rule part defines a DATE or DATE-TIME value that bounds the recurrence rule in an inclusive manner. +//> +//> If the value specified by UNTIL is synchronized with the specified recurrence, this DATE or DATE-TIME becomes the last instance of the recurrence. +//> If the "DTSTART" property is specified as a date with local time, then the UNTIL rule part MUST also be specified as a date with local time. +//> If the "DTSTART" property is specified as a date with UTC time or a date with local time and time zone reference, then the UNTIL rule part MUST be specified as a date with UTC time. +//> If not present, and the COUNT rule part is also not present, the "RRULE" is considered to repeat forever. + * DateTime( +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ + // if dtstart is defined and a datetime, until must also be a datetime if defined + dtstart?.ifNonNull((it) -> it is DateTime) ?? true, +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/dtstart. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_63 +// ^^ reference local it_63 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ + dtstart?.ifNonNull((it) -> utc == (it as DateTime).utc) ?? true, +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/dtstart. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_64 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/utc. +// ^^ reference local it_64 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/utc. + utc.implies(tzid == null) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/DateTime.pkl`/utc. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/tzid. + ) + |Date( +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ + // if dtstart is defined and a date, until must also be a date if defined + dtstart?.ifNonNull((it) -> it is Date) ?? true, +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/dtstart. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_69 +// ^^ reference local it_69 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ + tzid == null +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/tzid. + ) + )? + + /// The COUNT rule part defines the number of occurrences at which to range-bound the recurrence. + /// + /// The "DTSTART" property value always counts as the first occurrence. + count: Int(this > 0)?( +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/count. +//documentation +//> The COUNT rule part defines the number of occurrences at which to range-bound the recurrence. +//> +//> The "DTSTART" property value always counts as the first occurrence. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + !(this != null && until != null) || throw("count and until may not both be set") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/until. + ) + + /// The BYSECOND rule part specifies one or more seconds within a minute. + bysecond: Listing( +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/bysecond. +//documentation +//> The BYSECOND rule part specifies one or more seconds within a minute. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + !isEmpty, +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + !(dtstart is Date) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ + )? + + /// The BYMINUTE rule part specifies one or more minutes within an hour. + byminute: Listing( +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/byminute. +//documentation +//> The BYMINUTE rule part specifies one or more minutes within an hour. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + !isEmpty, +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + !(dtstart is Date) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ + )? + + /// The BYHOUR rule part specifies one or more hours of the day. + byhour: Listing( +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/byhour. +//documentation +//> The BYHOUR rule part specifies one or more hours of the day. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + !isEmpty, +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + !(dtstart is Date) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ + )? + + /// The BYDAY rule part specifies one or more days of the week. + /// + /// Each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer. + /// If present, this indicates the nth occurrence of a specific day within the MONTHLY or YEARLY "RRULE". + /// For example, within a MONTHLY rule, +1MO (or simply 1MO) represents the first Monday within the month, whereas -1MO represents the last Monday of the month. + /// The numeric value in a BYDAY rule part with the FREQ rule part set to YEARLY corresponds to an offset within the month when the BYMONTH rule part is present, and corresponds to an offset within the year when the BYWEEKNO or BYMONTH rule parts are present. + /// + /// If an integer modifier is not present, it means all days of this type within the specified frequency. + /// For example, within a MONTHLY rule, MO represents all Mondays within the month. + byday: Listing< +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/byday. +//documentation +//> The BYDAY rule part specifies one or more days of the week. +//> +//> Each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer. +//> If present, this indicates the nth occurrence of a specific day within the MONTHLY or YEARLY "RRULE". +//> For example, within a MONTHLY rule, +1MO (or simply 1MO) represents the first Monday within the month, whereas -1MO represents the last Monday of the month. +//> The numeric value in a BYDAY rule part with the FREQ rule part set to YEARLY corresponds to an offset within the month when the BYMONTH rule part is present, and corresponds to an offset within the year when the BYWEEKNO or BYMONTH rule parts are present. +//> +//> If an integer modifier is not present, it means all days of this type within the specified frequency. +//> For example, within a MONTHLY rule, MO represents all Mondays within the month. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + WeekdayString +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/WeekdayString# + |* Weekday( +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Weekday# + // The BYDAY rule part MUST NOT be specified with a numeric value when the FREQ rule part is not set to MONTHLY or YEARLY. + (weeknum != null).implies(freq == "MONTHLY" || freq == "YEARLY"), +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Weekday#weeknum. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/freq. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/freq. + // Furthermore, the BYDAY rule part MUST NOT be specified with a numeric value with the FREQ rule part set to YEARLY when the BYWEEKNO rule part is specified. + (weeknum != null && freq == "YEARLY").implies(byweekno == null) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/Weekday#weeknum. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/freq. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/byweekno. + ) + >(!isEmpty)? +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + + /// The BYMONTHDAY rule part specifies one or more days of the month. + /// + /// Negative values represent days counting back from the end of a month. + /// For example, -10 represents the tenth to the last day of the month. + bymonthday: Listing( +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/bymonthday. +//documentation +//> The BYMONTHDAY rule part specifies one or more days of the month. +//> +//> Negative values represent days counting back from the end of a month. +//> For example, -10 represents the tenth to the last day of the month. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + !isEmpty, +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + freq != "MONTHLY" +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/freq. + )? + + /// The BYYEARDAY rule part specifies one or more days of the year. + /// + /// Negative values represent days counting back from the end of a year. + /// For example, -1 represents the last day of the year (December 31st) and -306 represents the 306th to the last day of the year (March 1st). + byyearday: Listing( +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/byyearday. +//documentation +//> The BYYEARDAY rule part specifies one or more days of the year. +//> +//> Negative values represent days counting back from the end of a year. +//> For example, -1 represents the last day of the year (December 31st) and -306 represents the 306th to the last day of the year (March 1st). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + !isEmpty, +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + freq != "DAILY", +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/freq. + freq != "WEEKLY", +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/freq. + freq != "MONTHLY" +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/freq. + )? + + /// The BYWEEKNO rule part specifies one or more ordinals specifying weeks of the year. + /// + /// This corresponds to weeks according to week numbering as defined in [ISO.8601.2004](https://datatracker.ietf.org/doc/html/rfc5545#ref-ISO.8601.2004). + /// A week is defined as a seven day period, starting on the day of the week defined to be the week start (see [wkst]). + /// Week number one of the calendar year is the first week that contains at least four (4) days in that calendar year. + /// + /// Note: Assuming a Monday week start, week 53 can only occur when Thursday is January 1 or if it is a leap year and Wednesday is January 1. + byweekno: Listing( +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/byweekno. +//documentation +//> The BYWEEKNO rule part specifies one or more ordinals specifying weeks of the year. +//> +//> This corresponds to weeks according to week numbering as defined in [ISO.8601.2004](https://datatracker.ietf.org/doc/html/rfc5545#ref-ISO.8601.2004). +//> A week is defined as a seven day period, starting on the day of the week defined to be the week start (see [`wkst`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/icalendar/type/Recur.pkl#L158,C1)). +//> Week number one of the calendar year is the first week that contains at least four (4) days in that calendar year. +//> +//> Note: Assuming a Monday week start, week 53 can only occur when Thursday is January 1 or if it is a leap year and Wednesday is January 1. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + !isEmpty, +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + freq == "YEARLY" +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/freq. + )? + + /// The BYMONTH rule part specifies one or more months of the year. + bymonth: Listing(!isEmpty)? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/bymonth. +//documentation +//> The BYMONTH rule part specifies one or more months of the year. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + + /// The WKST rule part specifies the day on which the workweek starts. + /// + /// This is significant when a WEEKLY "RRULE" has an interval greater than 1, and a BYDAY rule part is specified. + /// This is also significant when in a YEARLY "RRULE" when a BYWEEKNO rule part is specified. + /// Defaults to "MO" if not specified. + wkst: WeekdayString? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/wkst. +//documentation +//> The WKST rule part specifies the day on which the workweek starts. +//> +//> This is significant when a WEEKLY "RRULE" has an interval greater than 1, and a BYDAY rule part is specified. +//> This is also significant when in a YEARLY "RRULE" when a BYWEEKNO rule part is specified. +//> Defaults to "MO" if not specified. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/WeekdayString# + + /// The BYSETPOS rule part specifies one or more values that corresponds to the nth occurrence within the set of recurrence instances specified by the rule. + /// + /// BYSETPOS operates on a set of recurrence instances in one interval of the recurrence rule. + /// For example, in a WEEKLY rule, the interval would be one week A set of recurrence instances starts at the beginning of the interval defined by the FREQ rule part. + bysetpos: Listing( +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/bysetpos. +//documentation +//> The BYSETPOS rule part specifies one or more values that corresponds to the nth occurrence within the set of recurrence instances specified by the rule. +//> +//> BYSETPOS operates on a set of recurrence instances in one interval of the recurrence rule. +//> For example, in a WEEKLY rule, the interval would be one week A set of recurrence instances starts at the beginning of the interval defined by the FREQ rule part. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + !isEmpty, +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + List(bysecond, byminute, byhour, byday, bymonthday, byyearday, byweekno, bymonth) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/bysecond. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/byminute. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/byhour. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/byday. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/bymonthday. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/byyearday. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/byweekno. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/bymonth. + .filterNonNull().length > 0 // RFC is a little ambiguous on this one, should it be >0 or ==1? +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. + )? + + /// Serialize the recurrence rule. + /// + /// Note: this departs from the RFC around line lengths. + /// The 75-character line limit and folding behavior are not enforced. + /// Lines are separated by "\n" (LF) and not "\r\n" (CRLF). + /// Ref: https://datatracker.ietf.org/doc/html/rfc5545#section-3.1 + function toString(): String = List( +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/toString(). +// documentation +// > Serialize the recurrence rule. +// > +// > Note: this departs from the RFC around line lengths. +// > The 75-character line limit and folding behavior are not enforced. +// > Lines are separated by "\n" (LF) and not "\r\n" (CRLF). +// > Ref: https://datatracker.ietf.org/doc/html/rfc5545#section-3.1 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + dtstart?.ifNonNull((start) -> List( +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/dtstart. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^^^^ definition local start_177 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + "DTSTART", + if (dtstart is Date) ";VALUE=DATE" else null, +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/dtstart. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Date.pkl`/ + tzid?.ifNonNull((tz) -> ";TZID=\(tz)"), +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Recur.pkl`/tzid. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local tz_180 +// ^^ reference local tz_180 + ":\(start)" +// ^^^^^ reference local start_177 + ).filterNonNull().join("")), +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + let (parts = module.toMap() +// ^^^^^ definition local parts_183 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). + .remove("tzid").remove("dtstart") +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#remove(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#remove(). + .filter((_, v) -> v != null) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^ definition local v_185 +// ^ reference local v_185 + .entries.map((entry) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^^ definition local entry_186 + let (value = if (entry.value is Listing) +// ^^^^^ definition local value_187 +// ^^^^^ reference local entry_186 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#value. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + // https://github.com/apple/pkl/issues/923 :( + // entry.value.join(",") + entry.value.toList().map((it) -> it.toString()).join(",") +// ^^^^^ reference local entry_186 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#value. +// ^^ definition local it_190 +// ^^ reference local it_190 + else entry.value.toString()) +// ^^^^^ reference local entry_186 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#value. + "\(entry.key.toUpperCase())=\(value)" +// ^^^^^ reference local entry_186 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#key. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toUpperCase(). +// ^^^^^ reference local value_187 + ) + ) + if (!parts.isEmpty) "RRULE:\(parts.join(";"))" else null +// ^^^^^ reference local parts_183 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^^^ reference local parts_183 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + ).filterNonNull().join("\n") +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + diff --git a/pkl-pantrysnapshot/icalendar/type/Time.pkl b/pkl-pantrysnapshot/icalendar/type/Time.pkl new file mode 100755 index 00000000..74c13782 --- /dev/null +++ b/pkl-pantrysnapshot/icalendar/type/Time.pkl @@ -0,0 +1,108 @@ + //===----------------------------------------------------------------------===// + // Copyright © 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// This value type is used to identify values that contain a time of day. + /// + /// https://datatracker.ietf.org/doc/html/rfc5545#section-3.3.12 + module icalendar.type.Time +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/ + + import "Time.pkl" + + // language=Regexp + const hidden timeRegex = "([01][0-9]|2[0-3])([0-5][0-9])([0-5][0-9]|60)Z?" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/timeRegex. + typealias TimeString = String(matches(Regex(timeRegex))) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/TimeString# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/timeRegex. + + /// Hour value. + h: Int(isBetween(0, 23)) +//^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/h. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + + /// Minute value. + m: Int(isBetween(0, 59)) +//^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/m. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + + /// Seconds value. + /// + /// A value of 60 allows accounting for positive leap seconds. + s: Int(isBetween(0, 60)) +//^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/s. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + + /// Indicates that the time is UTC, not local. + utc: Boolean +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/utc. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + function toString(): String = List( +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/toString(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + h.toString().padStart(2, "0"), +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/h. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + m.toString().padStart(2, "0"), +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/m. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + s.toString().padStart(2, "0"), +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/s. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + if (utc) "Z" else "" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/utc. + ).join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + /// Parse a [TimeString] into a [Time]. + const function Time(input: TimeString): Time = new { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/Time(). +// documentation +// > Parse a [`TimeString`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/icalendar/type/Time.pkl#L25,C11) into a [`Time`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/icalendar/type/Time.pkl#L19,C1). +// ^^^^^ definition local input_49 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/TimeString# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/ + h = input.substring(0, 2).toInt() +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/h. +// ^^^^^ reference local input_49 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + m = input.substring(2, 4).toInt() +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/m. +// ^^^^^ reference local input_49 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + s = input.substring(4, 6).toInt() +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/s. +// ^^^^^ reference local input_49 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + utc = input.getOrNull(6) == "Z" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/icalendar 0.1.1 `type/Time.pkl`/utc. +// ^^^^^ reference local input_49 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#getOrNull(). + } + diff --git a/pkl-pantrysnapshot/io.prometheus/Configuration.pkl b/pkl-pantrysnapshot/io.prometheus/Configuration.pkl new file mode 100755 index 00000000..f8597a40 --- /dev/null +++ b/pkl-pantrysnapshot/io.prometheus/Configuration.pkl @@ -0,0 +1,1764 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Prometheus is configured via command-line flags and a configuration file. + /// + /// While the command-line flags configure immutable system parameters + /// (such as storage locations, amount of data to keep on disk and in memory, etc.), + /// the configuration file defines everything related to scraping + /// [jobs and their instances](https://prometheus.io/docs/concepts/jobs_instances/), + /// as well as which + /// [rule files to load](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#configuring-rules). + /// + /// To view all available command-line flags, run `./prometheus -h`. + /// + /// Prometheus can reload its configuration at runtime. + /// If the new configuration is not well-formed, the changes will not be applied. + /// A configuration reload is triggered by sending a `SIGHUP` to the Prometheus process + /// or sending a HTTP POST request to the `/-/reload` endpoint + /// (when the `--web.enable-lifecycle` flag is enabled). + /// This will also reload any configured rule files. + /// + /// More details: + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/minPklVersion. + open module io.prometheus.Configuration +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ + + extends "PrometheusObject.pkl" + + /// The global configuration specifies parameters that are valid in all other configuration contexts. + /// + /// They also serve as defaults for other configuration sections. + global: GlobalConfig? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/global. +//documentation +//> The global configuration specifies parameters that are valid in all other configuration contexts. +//> +//> They also serve as defaults for other configuration sections. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/GlobalConfig# + + /// Alerting specifies settings related to the Alertmanager. + alerting: AlertingConfig? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/alerting. +//documentation +//> Alerting specifies settings related to the Alertmanager. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertingConfig# + + /// A list of scrape configurations. + scrape_configs: Listing? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/scrape_configs. +//documentation +//> A list of scrape configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig# + + /// Settings related to the remote write feature. + remote_write: Listing? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/remote_write. +//documentation +//> Settings related to the remote write feature. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig# + + /// Settings related to the remote read feature. + remote_read: Listing? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/remote_read. +//documentation +//> Settings related to the remote read feature. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteReadConfig# + + /// A list of globs. Rules and alerts are read from all matching files. + rule_files: Listing? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/rule_files. +//documentation +//> A list of globs. Rules and alerts are read from all matching files. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + class GlobalConfig { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/GlobalConfig# + /// How frequently to evaluate rules + /// + /// Default: `1.min` + evaluation_interval: Duration? +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/GlobalConfig#evaluation_interval. +// documentation +// > How frequently to evaluate rules +// > +// > Default: `1.min` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// The labels to add to any time series or alerts when communicating + /// with external systems (federation, remote storage, Alertmanager). + external_labels: Labels? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/GlobalConfig#external_labels. +// documentation +// > The labels to add to any time series or alerts when communicating +// > with external systems (federation, remote storage, Alertmanager). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Labels# + + /// File to which PromQL queries are logged. + /// + /// Reloading the configuration will reopen the file. + query_log_file: String? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/GlobalConfig#query_log_file. +// documentation +// > File to which PromQL queries are logged. +// > +// > Reloading the configuration will reopen the file. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// How long until a scrape request times out. + /// + /// Default if omitted: `10.s` + scrape_timeout: Duration? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/GlobalConfig#scrape_timeout. +// documentation +// > How long until a scrape request times out. +// > +// > Default if omitted: `10.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// How frequently to evaluate rules. + /// + /// Default if omitted: `1.min` + scrape_interval: Duration? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/GlobalConfig#scrape_interval. +// documentation +// > How frequently to evaluate rules. +// > +// > Default if omitted: `1.min` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + } + + /// A set of targets and parameters describing how to scrape them. + /// + /// In the general case, one scrape configuration specifies a single job. + /// In advanced configurations, this may change. + /// + /// Targets may be statically configured via [static_configs] + /// or dynamically discovered using one of the supported service-discovery mechanisms. + /// + /// Additionally, [relabel_configs] allow advanced modifications to any target and its labels before scraping. + /// + /// More details: + open class ScrapeConfig extends HttpClientConfig { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig# +// documentation +// > A set of targets and parameters describing how to scrape them. +// > +// > In the general case, one scrape configuration specifies a single job. +// > In advanced configurations, this may change. +// > +// > Targets may be statically configured via [`static_configs`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L168,C3) +// > or dynamically discovered using one of the supported service-discovery mechanisms. +// > +// > Additionally, [`relabel_configs`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L171,C3) allow advanced modifications to any target and its labels before scraping. +// > +// > More details: +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig# + /// The job name assigned to scraped metrics by default. + job_name: String +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#job_name. +// documentation +// > The job name assigned to scraped metrics by default. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// How frequently to scrape targets from this job. + /// + /// Default if omitted: [GlobalConfig.scrape_interval] + scrape_interval: Duration? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#scrape_interval. +// documentation +// > How frequently to scrape targets from this job. +// > +// > Default if omitted: [`GlobalConfig.scrape_interval`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L83,C3) +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Per-scrape timeout when scraping this job. + /// + /// Default if omitted: [GlobalConfig.scrape_timeout] + scrape_timeout: Duration? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#scrape_timeout. +// documentation +// > Per-scrape timeout when scraping this job. +// > +// > Default if omitted: [`GlobalConfig.scrape_timeout`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L78,C3) +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// The HTTP resource path on which to fetch metrics from targets. + /// + /// Default if omitted: `"/metrics"` + metrics_path: String? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#metrics_path. +// documentation +// > The HTTP resource path on which to fetch metrics from targets. +// > +// > Default if omitted: `"/metrics"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Controls how Prometheus handles conflicts between labels that are + /// already present in scraped data and labels that Prometheus would attach + /// server-side ("job" and "instance" labels, manually configured target + /// labels, and labels generated by service discovery implementations). + /// + /// If [true], label conflicts are resolved by keeping label + /// values from the scraped data and ignoring the conflicting server-side labels. + /// + /// If [false], label conflicts are resolved by renaming conflicting labels + /// in the scraped data to "exported_" (for example "exported_instance", "exported_job") + /// and then attaching server-side labels. + /// + /// Setting [honor_labels] to [true] is useful for use cases such as federation + /// and scraping the Pushgateway, where all labels specified in the target should be preserved. + /// + /// Note that any globally configured [GlobalConfig.external_labels] are unaffected by this setting. + /// In communication with external systems, they are always applied only + /// when a time series does not have a given label yet and are ignored otherwise. + /// + /// Default if omitted: [false] + honor_labels: Boolean? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#honor_labels. +// documentation +// > Controls how Prometheus handles conflicts between labels that are +// > already present in scraped data and labels that Prometheus would attach +// > server-side ("job" and "instance" labels, manually configured target +// > labels, and labels generated by service discovery implementations). +// > +// > If `true`, label conflicts are resolved by keeping label +// > values from the scraped data and ignoring the conflicting server-side labels. +// > +// > If `false`, label conflicts are resolved by renaming conflicting labels +// > in the scraped data to "exported_" (for example "exported_instance", "exported_job") +// > and then attaching server-side labels. +// > +// > Setting [`honor_labels`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L136,C3) to `true` is useful for use cases such as federation +// > and scraping the Pushgateway, where all labels specified in the target should be preserved. +// > +// > Note that any globally configured [`GlobalConfig.external_labels`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L68,C3) are unaffected by this setting. +// > In communication with external systems, they are always applied only +// > when a time series does not have a given label yet and are ignored otherwise. +// > +// > Default if omitted: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Controls whether Prometheus respects the timestamps present in scraped data. + /// + /// If [true], the timestamps of the metrics exposed by the target will be used. + /// + /// If [false], the timestamps of the metrics exposed by the target will be ignored. + /// + /// Default if omitted: [true] + honor_timestamps: Boolean? +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#honor_timestamps. +// documentation +// > Controls whether Prometheus respects the timestamps present in scraped data. +// > +// > If `true`, the timestamps of the metrics exposed by the target will be used. +// > +// > If `false`, the timestamps of the metrics exposed by the target will be ignored. +// > +// > Default if omitted: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Configures the protocol scheme used for requests. + /// + /// Default if omitted: `"http"` + scheme: Scheme? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#scheme. +// documentation +// > Configures the protocol scheme used for requests. +// > +// > Default if omitted: `"http"` +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Scheme# + + /// Optional HTTP URL parameters. + params: Mapping>? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#params. +// documentation +// > Optional HTTP URL parameters. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// List of HTTP service discovery configurations. + http_sd_configs: Listing? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#http_sd_configs. +// documentation +// > List of HTTP service discovery configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpSdConfig# + + /// List of Kubernetes service discovery configurations. + kubernetes_sd_configs: Listing? +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#kubernetes_sd_configs. +// documentation +// > List of Kubernetes service discovery configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfig# + + /// List of file service discovery configurations. + file_sd_configs: Listing? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#file_sd_configs. +// documentation +// > List of file service discovery configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/FileSdConfig# + + /// List of DNS-based service discovery configurations. + dns_sd_configs: Listing? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#dns_sd_configs. +// documentation +// > List of DNS-based service discovery configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/DnsSdConfig# + + /// List of labeled statically configured targets for this job. + static_configs: Listing? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#static_configs. +// documentation +// > List of labeled statically configured targets for this job. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/StaticConfig# + + /// List of target relabel configurations. + relabel_configs: Listing? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#relabel_configs. +// documentation +// > List of target relabel configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig# + + /// List of metric relabel configurations. + metric_relabel_configs: Listing? +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#metric_relabel_configs. +// documentation +// > List of metric relabel configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig# + + /// Per-scrape limit on number of scraped samples that will be accepted. + /// + /// If more than this number of samples are present after metric relabeling, + /// the entire scrape will be treated as failed. + /// `0` means no limit. + /// + /// Default if omitted: `0` + sample_limit: UInt? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#sample_limit. +// documentation +// > Per-scrape limit on number of scraped samples that will be accepted. +// > +// > If more than this number of samples are present after metric relabeling, +// > the entire scrape will be treated as failed. +// > `0` means no limit. +// > +// > Default if omitted: `0` +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Per-scrape config limit on number of unique targets that will be accepted. + /// + /// If more than this number of targets are present after target relabeling, + /// Prometheus will mark the targets as failed without scraping them. + /// `0` means no limit. + /// + /// This is an experimental feature, this behaviour could change in the future. + /// + /// Default if omitted: `0` + target_limit: UInt? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ScrapeConfig#target_limit. +// documentation +// > Per-scrape config limit on number of unique targets that will be accepted. +// > +// > If more than this number of targets are present after target relabeling, +// > Prometheus will mark the targets as failed without scraping them. +// > `0` means no limit. +// > +// > This is an experimental feature, this behaviour could change in the future. +// > +// > Default if omitted: `0` +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + } + + /// Allow retrieving scrape targets from Kubernetes' REST API + /// and always staying synchronized with the cluster state. + /// + /// One of the following role types can be configured to discover targets: + /// + /// More details: + class KubernetesSdConfig extends HttpClientConfig { +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfig# +// documentation +// > Allow retrieving scrape targets from Kubernetes' REST API +// > and always staying synchronized with the cluster state. +// > +// > One of the following role types can be configured to discover targets: +// > +// > More details: +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig# + /// The Kubernetes role of entities that should be discovered. + role: KubernetesSdConfigRole +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfig#role. +// documentation +// > The Kubernetes role of entities that should be discovered. +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigRole# + + /// Optional namespace discovery. + /// + /// Default if omitted: all namespaces are used + namespaces: NamespaceSpec? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfig#namespaces. +// documentation +// > Optional namespace discovery. +// > +// > Default if omitted: all namespaces are used +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/NamespaceSpec# + + /// The API server addresses. + /// + /// If left empty, Prometheus is assumed to run inside of the cluster + /// and will discover API servers automatically and use the pod's CA certificate + /// and bearer token file at /var/run/secrets/kubernetes.io/serviceaccount/. + api_server: String? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfig#api_server. +// documentation +// > The API server addresses. +// > +// > If left empty, Prometheus is assumed to run inside of the cluster +// > and will discover API servers automatically and use the pod's CA certificate +// > and bearer token file at /var/run/secrets/kubernetes.io/serviceaccount/. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Optional label and field selectors to limit the discovery process to a subset of available resources. + /// + /// See + /// and + /// to learn more about the possible filters that can be used. + /// Endpoints role supports pod, service and endpoints selectors, + /// other roles only support selectors matching the role itself + /// (e.g. node role can only contain node selectors). + /// + /// Note: When making decision about using field/label selector, + /// make sure that this is the best approach - + /// it will prevent Prometheus from reusing single list/watch for all scrape configs. + /// This might result in a bigger load on the Kubernetes API, + /// because per each selector combination there will be additional LIST/WATCH. + /// On the other hand, if you just want to monitor small subset of pods in large cluster, + /// it's recommended to use selectors. + /// If selectors should be used or not depends on the particular situation. + selectors: Listing? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfig#selectors. +// documentation +// > Optional label and field selectors to limit the discovery process to a subset of available resources. +// > +// > See +// > and +// > to learn more about the possible filters that can be used. +// > Endpoints role supports pod, service and endpoints selectors, +// > other roles only support selectors matching the role itself +// > (e.g. node role can only contain node selectors). +// > +// > Note: When making decision about using field/label selector, +// > make sure that this is the best approach - +// > it will prevent Prometheus from reusing single list/watch for all scrape configs. +// > This might result in a bigger load on the Kubernetes API, +// > because per each selector combination there will be additional LIST/WATCH. +// > On the other hand, if you just want to monitor small subset of pods in large cluster, +// > it's recommended to use selectors. +// > If selectors should be used or not depends on the particular situation. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigSelector# + + /// Optional metadata to attach to discovered targets. + /// If omitted, no additional metadata is attached. + attach_metadata: KubernetesSdConfigAttachMetadata(node?.implies(role is KubernetesSdConfigRoleWithNodeMetadata) || true)? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfig#attach_metadata. +// documentation +// > Optional metadata to attach to discovered targets. +// > If omitted, no additional metadata is attached. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigAttachMetadata# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigAttachMetadata#node. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfig#role. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigRoleWithNodeMetadata# + } + + typealias KubernetesSdConfigRole = *"pod"|"service"|"node"|"endpoints"|"endpointslice"|"ingress" +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigRole# + + /// [KubernetesSdConfig.role] values that [KubernetesSdConfigAttachMetadata.node] may be enabled with + typealias KubernetesSdConfigRoleWithNodeMetadata = "pod"|"endpoints"|"endpointslice" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigRoleWithNodeMetadata# +// documentation +// > [`KubernetesSdConfig.role`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L205,C3) values that [`KubernetesSdConfigAttachMetadata.node`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L268,C3) may be enabled with + + class KubernetesSdConfigSelector { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigSelector# + role: KubernetesSdConfigRole +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigSelector#role. +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigRole# + + /// A `key=value` pair describing a Kubernetes resource label. + ///. + /// See . + label: String? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigSelector#label. +// documentation +// > A `key=value` pair describing a Kubernetes resource label. +// > . +// > See . +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A `key=value` pair describing a Kubernetes field selector. + /// + /// See . + field: String? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigSelector#field. +// documentation +// > A `key=value` pair describing a Kubernetes field selector. +// > +// > See . +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + class KubernetesSdConfigAttachMetadata { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigAttachMetadata# + /// Attaches node metadata to discovered targets. + /// Valid for roles: pod, endpoints, endpointslice. + /// When set to true, Prometheus must have permissions to get Nodes. + /// + /// Defaults to [false] + node: Boolean? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfigAttachMetadata#node. +// documentation +// > Attaches node metadata to discovered targets. +// > Valid for roles: pod, endpoints, endpointslice. +// > When set to true, Prometheus must have permissions to get Nodes. +// > +// > Defaults to `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + /// File-based service discovery provides a more generic way to configure static targets and + /// serves as an interface to plug in custom service discovery mechanisms. + /// + /// It reads a set of files containing a list of zero or more ``s. Changes to all + /// defined files are detected via disk watches and applied immediately. Files may be provided in + /// YAML or JSON format. Only changes resulting in well-formed target groups are applied. + class FileSdConfig { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/FileSdConfig# +// documentation +// > File-based service discovery provides a more generic way to configure static targets and +// > serves as an interface to plug in custom service discovery mechanisms. +// > +// > It reads a set of files containing a list of zero or more ``s. Changes to all +// > defined files are detected via disk watches and applied immediately. Files may be provided in +// > YAML or JSON format. Only changes resulting in well-formed target groups are applied. + /// Patterns for files from which target groups are extracted. + /// + /// Files may end with `.json`, `.yaml` or `.yml`. The last path segment may contain a single `*` + /// that matches any character sequence, e.g. `my/path/tg_*.json`. + files: Listing +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/FileSdConfig#files. +// documentation +// > Patterns for files from which target groups are extracted. +// > +// > Files may end with `.json`, `.yaml` or `.yml`. The last path segment may contain a single `*` +// > that matches any character sequence, e.g. `my/path/tg_*.json`. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#endsWith(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + + /// Refresh interval to re-read the files. + /// + /// Defaults to `5.m`. + refresh_interval: Duration? +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/FileSdConfig#refresh_interval. +// documentation +// > Refresh interval to re-read the files. +// > +// > Defaults to `5.m`. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + } + + /// DNS-based service discovery configuration allows specifying a set of DNS domain names which + /// are periodically queried to discover a list of targets. + /// + /// + class DnsSdConfig { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/DnsSdConfig# +// documentation +// > DNS-based service discovery configuration allows specifying a set of DNS domain names which +// > are periodically queried to discover a list of targets. +// > +// > + /// A list of DNS domain names to be queried. + names: Listing +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/DnsSdConfig#names. +// documentation +// > A list of DNS domain names to be queried. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The type of DNS query to perform. One of SRV, A, AAAA, MX or NS. + /// + /// Default if unspecified: `"SRV"` + type: ("SRV"|"A"|"AAAA"|"MX"|"NS")? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/DnsSdConfig#type. +// documentation +// > The type of DNS query to perform. One of SRV, A, AAAA, MX or NS. +// > +// > Default if unspecified: `"SRV"` + + /// The port number used if the query type is not SRV. + port: UInt16?((type != null && type != "SRV").implies(this != null)) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/DnsSdConfig#port. +// documentation +// > The port number used if the query type is not SRV. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt16# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/DnsSdConfig#type. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/DnsSdConfig#type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). + + /// The time after which the provided names are refreshed. + /// + /// Default if unspecified: `30.s` + refresh_internal: Duration? +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/DnsSdConfig#refresh_internal. +// documentation +// > The time after which the provided names are refreshed. +// > +// > Default if unspecified: `30.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + } + + class NamespaceSpec { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/NamespaceSpec# + names: Listing +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/NamespaceSpec#names. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// HTTP-based service discovery provides a more generic way to configure static targets + /// and serves as an interface to plug in custom service discovery mechanisms. + /// + /// It fetches targets from an HTTP endpoint containing a list of zero or more s. + /// The target must reply with an HTTP 200 response. The HTTP header Content-Type must be application/json, + /// and the body must be valid JSON. + /// + /// + class HttpSdConfig extends HttpClientConfig { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpSdConfig# +// documentation +// > HTTP-based service discovery provides a more generic way to configure static targets +// > and serves as an interface to plug in custom service discovery mechanisms. +// > +// > It fetches targets from an HTTP endpoint containing a list of zero or more s. +// > The target must reply with an HTTP 200 response. The HTTP header Content-Type must be application/json, +// > and the body must be valid JSON. +// > +// > +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig# + /// URL from which the targets are fetched. + url: String +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpSdConfig#url. +// documentation +// > URL from which the targets are fetched. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Refresh interval to re-query the endpoint. + /// + /// Defaults to `60.s` + refresh_interval: Duration? +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpSdConfig#refresh_interval. +// documentation +// > Refresh interval to re-query the endpoint. +// > +// > Defaults to `60.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + } + + /// Relabeling is a powerful tool to dynamically rewrite the label set of a target before it gets scraped. + /// + /// Multiple relabeling steps can be configured per scrape configuration. + /// They are applied to the label set of each target in order of their appearance in the configuration file. + /// + /// Initially, aside from the configured per-target labels, + /// a target's `job` label is set to the `job_name` value of the respective scrape configuration. + /// The `__address__` label is set to the `:` address of the target. + /// After relabeling, the `instance` label is set to the value of `__address__` + /// by default if it was not set during relabeling. + /// The `__scheme__` and `__metrics_path__` labels + /// are set to the scheme and metrics path of the target respectively. + /// The `__param_` label is set to the value of the first passed URL parameter called ``. + /// + /// Additional labels prefixed with `__meta_` may be available during the relabeling phase. + /// They are set by the service discovery mechanism that provided the target and vary between mechanisms. + /// + /// Labels starting with `__` will be removed from the label set after target relabeling is completed. + /// + /// If a relabeling step needs to store a label value only temporarily + /// (as the input to a subsequent relabeling step), use the `__tmp` label name prefix. + /// This prefix is guaranteed to never be used by Prometheus itself. + /// + /// More details: + class RelabelConfig { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig# +// documentation +// > Relabeling is a powerful tool to dynamically rewrite the label set of a target before it gets scraped. +// > +// > Multiple relabeling steps can be configured per scrape configuration. +// > They are applied to the label set of each target in order of their appearance in the configuration file. +// > +// > Initially, aside from the configured per-target labels, +// > a target's `job` label is set to the `job_name` value of the respective scrape configuration. +// > The `__address__` label is set to the `:` address of the target. +// > After relabeling, the `instance` label is set to the value of `__address__` +// > by default if it was not set during relabeling. +// > The `__scheme__` and `__metrics_path__` labels +// > are set to the scheme and metrics path of the target respectively. +// > The `__param_` label is set to the value of the first passed URL parameter called ``. +// > +// > Additional labels prefixed with `__meta_` may be available during the relabeling phase. +// > They are set by the service discovery mechanism that provided the target and vary between mechanisms. +// > +// > Labels starting with `__` will be removed from the label set after target relabeling is completed. +// > +// > If a relabeling step needs to store a label value only temporarily +// > (as the input to a subsequent relabeling step), use the `__tmp` label name prefix. +// > This prefix is guaranteed to never be used by Prometheus itself. +// > +// > More details: + /// The source labels select values from existing labels. + /// + /// Their content is concatenated using the configured separator + /// and matched against the configured regular expression for the replace, keep, and drop actions. + source_labels: Listing? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig#source_labels. +// documentation +// > The source labels select values from existing labels. +// > +// > Their content is concatenated using the configured separator +// > and matched against the configured regular expression for the replace, keep, and drop actions. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Separator placed between concatenated source label values. + separator: String? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig#separator. +// documentation +// > Separator placed between concatenated source label values. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Action to perform based on regex matching. + action: RelabelAction? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig#action. +// documentation +// > Action to perform based on regex matching. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelAction# + + /// Regular expression against which the extracted value is matched. + @SourceCode { language = "RegExp" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig#language. + regex: String(isRegex)? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig#regex. +// documentation +// > Regular expression against which the extracted value is matched. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isRegex. + + /// Label to which the resulting value is written in a replace action. + /// + /// Mandatory for replace actions. + /// Regex capture groups are available. + target_label: String? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig#target_label. +// documentation +// > Label to which the resulting value is written in a replace action. +// > +// > Mandatory for replace actions. +// > Regex capture groups are available. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Modulus to take of the hash of the source label values. + modulus: Int? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig#modulus. +// documentation +// > Modulus to take of the hash of the source label values. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Replacement value against which a regex replace is performed if the regular expression matches. + /// + /// Regex capture groups are available. + replacement: String? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig#replacement. +// documentation +// > Replacement value against which a regex replace is performed if the regular expression matches. +// > +// > Regex capture groups are available. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// Which relabel action to perform. + /// + /// * `"replace"`: Match `regex` against the concatenated `source_labels`. + /// Then, set `target_label` to `replacement`, with match group references + /// (`${1}`, `${2}`, ...) in `replacement` substituted by their value. + /// If `regex` does not match, no replacement takes place. + /// * `"lowercase"`: Maps the concatenated source_labels to their lower case. + /// * `"uppercase"`: Maps the concatenated source_labels to their upper case. + /// * `"keep"`: Drop targets for which `regex` does not match the concatenated `source_labels`. + /// * `"drop"`: Drop targets for which `regex` matches the concatenated `source_labels`. + /// * `"keepequal"`: Drop targets for which the concatenated source_labels do not match target_label. + /// * `"dropequal"`: Drop targets for which the concatenated source_labels do match target_label. + /// * `"hashmod"`: Set `target_label` to the `modulus` of a hash of the concatenated `source_labels`. + /// * `"labelmap"`: Match `regex` against all label names. + /// Then copy the values of the matching labels to label names given by `replacement` + /// with match group references (`${1}`, `${2}`, ...) in `replacement` substituted by their value. + /// * `"labeldrop"`: Match `regex` against all label names. + /// Any label that matches will be removed from the set of labels. + /// * `"labelkeep"`: Match `regex` against all label names. + typealias RelabelAction = "replace"|"lowercase"|"uppercase"|"keep"|"drop"|"keepequal"|"dropequal"|"hashmod"|"labelmap"|"labeldrop"|"labelkeep" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelAction# +// documentation +// > Which relabel action to perform. +// > +// > * `"replace"`: Match `regex` against the concatenated `source_labels`. +// > Then, set `target_label` to `replacement`, with match group references +// > (`${1}`, `${2}`, ...) in `replacement` substituted by their value. +// > If `regex` does not match, no replacement takes place. +// > * `"lowercase"`: Maps the concatenated source_labels to their lower case. +// > * `"uppercase"`: Maps the concatenated source_labels to their upper case. +// > * `"keep"`: Drop targets for which `regex` does not match the concatenated `source_labels`. +// > * `"drop"`: Drop targets for which `regex` matches the concatenated `source_labels`. +// > * `"keepequal"`: Drop targets for which the concatenated source_labels do not match target_label. +// > * `"dropequal"`: Drop targets for which the concatenated source_labels do match target_label. +// > * `"hashmod"`: Set `target_label` to the `modulus` of a hash of the concatenated `source_labels`. +// > * `"labelmap"`: Match `regex` against all label names. +// > Then copy the values of the matching labels to label names given by `replacement` +// > with match group references (`${1}`, `${2}`, ...) in `replacement` substituted by their value. +// > * `"labeldrop"`: Match `regex` against all label names. +// > Any label that matches will be removed from the set of labels. +// > * `"labelkeep"`: Match `regex` against all label names. + + /// Allows specifying a list of targets and a common label set for them. + /// + /// It is the canonical way to specify static targets in a scrape configuration. + /// + /// More details: + class StaticConfig { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/StaticConfig# +// documentation +// > Allows specifying a list of targets and a common label set for them. +// > +// > It is the canonical way to specify static targets in a scrape configuration. +// > +// > More details: + /// The targets specified by the static config. + targets: Listing? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/StaticConfig#targets. +// documentation +// > The targets specified by the static config. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Labels assigned to all metrics scraped from the targets. + labels: Labels? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/StaticConfig#labels. +// documentation +// > Labels assigned to all metrics scraped from the targets. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Labels# + } + + /// [write_relabel_configs] is relabeling applied to samples + /// before sending them to the remote endpoint. + /// + /// Write relabeling is applied after external labels. + /// This could be used to limit which samples are sent. + /// + /// There is a small demo (/documentation/examples/remote_storage) of how to use this functionality. + /// + /// More detail: + class RemoteWriteConfig extends HttpClientConfig { +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig# +// documentation +// > [`write_relabel_configs`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L448,C3) is relabeling applied to samples +// > before sending them to the remote endpoint. +// > +// > Write relabeling is applied after external labels. +// > This could be used to limit which samples are sent. +// > +// > There is a small demo (/documentation/examples/remote_storage) of how to use this functionality. +// > +// > More detail: +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig# + /// The URL of the endpoint to send samples to. + url: String +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig#url. +// documentation +// > The URL of the endpoint to send samples to. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Timeout for requests to the remote write endpoint. + /// + /// Default if omitted: `30.s` + remote_timeout: Duration? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig#remote_timeout. +// documentation +// > Timeout for requests to the remote write endpoint. +// > +// > Default if omitted: `30.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Custom HTTP headers to be sent along with each remote write request. + /// + /// Be aware that headers that are set by Prometheus itself can't be overwritten. + headers: Labels? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig#headers. +// documentation +// > Custom HTTP headers to be sent along with each remote write request. +// > +// > Be aware that headers that are set by Prometheus itself can't be overwritten. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Labels# + + /// List of remote write relabel configurations. + write_relabel_configs: Listing? +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig#write_relabel_configs. +// documentation +// > List of remote write relabel configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig# + + /// Name of the remote write config, which if specified must be unique among remote write configs. + /// + /// The name will be used in metrics and logging in place of a generated value + /// to help users distinguish between remote write configs. + name: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig#name. +// documentation +// > Name of the remote write config, which if specified must be unique among remote write configs. +// > +// > The name will be used in metrics and logging in place of a generated value +// > to help users distinguish between remote write configs. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + send_exemplars: Boolean? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig#send_exemplars. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + send_native_histograms: Boolean? +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig#send_native_histograms. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + protobuf_message: ("prometheus.WriteRequest"|"io.prometheus.write.v2.Request")? +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig#protobuf_message. + + /// Configures the queue used to write to remote storage. + queue_config: QueueConfig? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig#queue_config. +// documentation +// > Configures the queue used to write to remote storage. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/QueueConfig# + + /// Configures the sending of series metadata to remote storage. + /// + /// Metadata configuration is subject to change at any point or be removed in future releases. + metadata_config: MetadataConfig? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig#metadata_config. +// documentation +// > Configures the sending of series metadata to remote storage. +// > +// > Metadata configuration is subject to change at any point or be removed in future releases. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/MetadataConfig# + + local _self = this +// ^^^^^ definition local _self_470 + + /// Configures AWS's Signature Verification 4 signing process. + /// + /// Signature Verification signs requests. + /// To use the default credentials from the AWS SDK, use `sigv4 {}`. + sigv4: Sigv4Config?(atMostOneSet(List(this, _self.basic_auth, _self.authorization, _self.oauth2))) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteWriteConfig#sigv4. +// documentation +// > Configures AWS's Signature Verification 4 signing process. +// > +// > Signature Verification signs requests. +// > To use the default credentials from the AWS SDK, use `sigv4 {}`. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Sigv4Config# +// ^^^^^^^^^^^^ reference local atMostOneSet_797 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^ reference local _self_470 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#basic_auth. +// ^^^^^ reference local _self_470 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#authorization. +// ^^^^^ reference local _self_470 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#oauth2. + } + + class MetadataConfig { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/MetadataConfig# + /// Whether metric metadata is sent to remote storage or not. + /// + /// Default if omitted: [true] + send: Boolean? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/MetadataConfig#send. +// documentation +// > Whether metric metadata is sent to remote storage or not. +// > +// > Default if omitted: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// How frequently metric metadata is sent to remote storage. + /// + /// Default if omitted: `1.min` + send_interval: Duration? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/MetadataConfig#send_interval. +// documentation +// > How frequently metric metadata is sent to remote storage. +// > +// > Default if omitted: `1.min` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Maximum number of samples per send. + /// + /// Default if omitted: `2000` + max_samples_per_send: Int? +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/MetadataConfig#max_samples_per_send. +// documentation +// > Maximum number of samples per send. +// > +// > Default if omitted: `2000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + } + + class QueueConfig { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/QueueConfig# + /// Number of samples to buffer per shard before we block reading of more samples from the WAL. + /// + /// It is recommended to have enough capacity in each shard to buffer several requests + /// to keep throughput up while processing occasional slow remote requests. + /// + /// Default if omitted: `2500` + capacity: Int? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/QueueConfig#capacity. +// documentation +// > Number of samples to buffer per shard before we block reading of more samples from the WAL. +// > +// > It is recommended to have enough capacity in each shard to buffer several requests +// > to keep throughput up while processing occasional slow remote requests. +// > +// > Default if omitted: `2500` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Maximum number of shards, i.e. amount of concurrency. + /// + /// Default if omitted: `200` + max_shards: Int? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/QueueConfig#max_shards. +// documentation +// > Maximum number of shards, i.e. amount of concurrency. +// > +// > Default if omitted: `200` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Minimum number of shards, i.e. amount of concurrency. + /// + /// Default if omitted: `1` + min_shards: Int? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/QueueConfig#min_shards. +// documentation +// > Minimum number of shards, i.e. amount of concurrency. +// > +// > Default if omitted: `1` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Maximum number of samples per send. + /// + /// Default if omitted: `500` + max_samples_per_send: Int? +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/QueueConfig#max_samples_per_send. +// documentation +// > Maximum number of samples per send. +// > +// > Default if omitted: `500` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Maximum time a sample will wait in buffer. + /// + /// Default if omitted: `5.s` + batch_send_deadline: Duration? +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/QueueConfig#batch_send_deadline. +// documentation +// > Maximum time a sample will wait in buffer. +// > +// > Default if omitted: `5.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Initial retry delay. Gets doubled for every retry. + /// + /// Default if omitted: `30.ms` + min_backoff: Duration? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/QueueConfig#min_backoff. +// documentation +// > Initial retry delay. Gets doubled for every retry. +// > +// > Default if omitted: `30.ms` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Maximum retry delay. + /// + /// Default if omitted: `100.ms` + max_backoff: Duration? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/QueueConfig#max_backoff. +// documentation +// > Maximum retry delay. +// > +// > Default if omitted: `100.ms` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Consider HTTP 429 responses retry-able. + /// + /// Default if omitted: [false] + retry_on_http_429: Boolean? +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/QueueConfig#retry_on_http_429. +// documentation +// > Consider HTTP 429 responses retry-able. +// > +// > Default if omitted: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Samples older than the limit will be dropped. + /// + /// Default if omitted: do not drop old samples + sample_age_limit: Duration? +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/QueueConfig#sample_age_limit. +// documentation +// > Samples older than the limit will be dropped. +// > +// > Default if omitted: do not drop old samples +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + } + + class AlertingConfig { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertingConfig# + alertmanagers: Listing? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertingConfig#alertmanagers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig# + } + + /// Specifies Alertmanager instances the Prometheus server sends alerts to. + /// + /// Also provides parameters to configure how to communicate with these Alertmanagers. + /// + /// Alertmanagers may be statically configured via the [static_configs] parameter + /// or dynamically discovered using one of the supported service-discovery mechanisms. + /// + /// Additionally, [relabel_configs] allow selecting Alertmanagers + /// from discovered entities and provide advanced modifications to the used API path, + /// which is exposed through the `__alerts_path__` label. + /// + /// More details: + class AlertManagerConfig extends HttpClientConfig { +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig# +// documentation +// > Specifies Alertmanager instances the Prometheus server sends alerts to. +// > +// > Also provides parameters to configure how to communicate with these Alertmanagers. +// > +// > Alertmanagers may be statically configured via the [`static_configs`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L592,C3) parameter +// > or dynamically discovered using one of the supported service-discovery mechanisms. +// > +// > Additionally, [`relabel_configs`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L595,C3) allow selecting Alertmanagers +// > from discovered entities and provide advanced modifications to the used API path, +// > which is exposed through the `__alerts_path__` label. +// > +// > More details: +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig# + /// The api version of Alertmanager. + /// + /// Default if omitted: `"v1"` + api_version: String? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#api_version. +// documentation +// > The api version of Alertmanager. +// > +// > Default if omitted: `"v1"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Prefix for the HTTP path alerts are pushed to. + path_prefix: String? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#path_prefix. +// documentation +// > Prefix for the HTTP path alerts are pushed to. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Configures the protocol scheme used for requests. + scheme: Scheme? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#scheme. +// documentation +// > Configures the protocol scheme used for requests. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Scheme# + + /// Per-target Alertmanager timeout when pushing alerts. + /// + /// Default if omitted: `10.s` + timeout: Duration? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#timeout. +// documentation +// > Per-target Alertmanager timeout when pushing alerts. +// > +// > Default if omitted: `10.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// List of HTTP service discovery configurations. + http_sd_configs: Listing? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#http_sd_configs. +// documentation +// > List of HTTP service discovery configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpSdConfig# + + /// List of Kubernetes service discovery configurations. + kubernetes_sd_configs: Listing? +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#kubernetes_sd_configs. +// documentation +// > List of Kubernetes service discovery configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/KubernetesSdConfig# + + /// List of file service discovery configurations. + file_sd_configs: Listing? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#file_sd_configs. +// documentation +// > List of file service discovery configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/FileSdConfig# + + /// List of DNS-based service discovery configurations. + dns_sd_configs: Listing? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#dns_sd_configs. +// documentation +// > List of DNS-based service discovery configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/DnsSdConfig# + + /// List of labeled statically configured Alertmanagers. + static_configs: Listing? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#static_configs. +// documentation +// > List of labeled statically configured Alertmanagers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/StaticConfig# + + /// List of Alertmanager relabel configurations. + relabel_configs: Listing? +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#relabel_configs. +// documentation +// > List of Alertmanager relabel configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig# + + /// List of alert relabel configurations. + alert_relabel_configs: Listing? +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#alert_relabel_configs. +// documentation +// > List of alert relabel configurations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RelabelConfig# + + local _self = this +// ^^^^^ definition local _self_600 + + /// Configures AWS's Signature Verification 4 signing process. + /// + /// Signature Verification signs requests. + /// To use the default credentials from the AWS SDK, use `sigv4 {}`. + sigv4: Sigv4Config?(atMostOneSet(List(this, _self.basic_auth, _self.authorization, _self.oauth2))) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/AlertManagerConfig#sigv4. +// documentation +// > Configures AWS's Signature Verification 4 signing process. +// > +// > Signature Verification signs requests. +// > To use the default credentials from the AWS SDK, use `sigv4 {}`. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Sigv4Config# +// ^^^^^^^^^^^^ reference local atMostOneSet_797 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^ reference local _self_600 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#basic_auth. +// ^^^^^ reference local _self_600 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#authorization. +// ^^^^^ reference local _self_600 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#oauth2. + } + + class RemoteReadConfig extends HttpClientConfig { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteReadConfig# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig# + /// The URL of the endpoint to query from. + url: String +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteReadConfig#url. +// documentation +// > The URL of the endpoint to query from. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Name of the remote read config, which if specified must be unique among remote read configs. + /// + /// The name will be used in metrics and logging in place of a generated value + /// to help users distinguish between remote read configs. + name: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteReadConfig#name. +// documentation +// > Name of the remote read config, which if specified must be unique among remote read configs. +// > +// > The name will be used in metrics and logging in place of a generated value +// > to help users distinguish between remote read configs. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// An optional list of equality matchers which have to be present + /// in a selector to query the remote read endpoint. + required_matchers: Labels? +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteReadConfig#required_matchers. +// documentation +// > An optional list of equality matchers which have to be present +// > in a selector to query the remote read endpoint. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Labels# + + /// Timeout for requests to the remote read endpoint. + /// + /// Default if omitted: `1.min` + remote_timeout: Duration? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteReadConfig#remote_timeout. +// documentation +// > Timeout for requests to the remote read endpoint. +// > +// > Default if omitted: `1.min` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Whether reads should be made for queries for time ranges + /// that the local storage should have complete data for. + read_recent: Boolean? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/RemoteReadConfig#read_recent. +// documentation +// > Whether reads should be made for queries for time ranges +// > that the local storage should have complete data for. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + class Sigv4Config { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Sigv4Config# + /// The AWS region (if blank, the region from the default credentials chain is used). + region: String? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Sigv4Config#region. +// documentation +// > The AWS region (if blank, the region from the default credentials chain is used). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The AWS API access key. + access_key: String? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Sigv4Config#access_key. +// documentation +// > The AWS API access key. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The AWS API secret key. + secret_key: String? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Sigv4Config#secret_key. +// documentation +// > The AWS API secret key. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// AWS profile used to authenticate. + profile: String? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Sigv4Config#profile. +// documentation +// > AWS profile used to authenticate. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// AWS Role ARN, an alternative to using AWS API Keys. + role_arn: String? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Sigv4Config#role_arn. +// documentation +// > AWS Role ARN, an alternative to using AWS API Keys. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + abstract class ProxyConfig { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ProxyConfig# + /// Optional proxy URL. + proxy_url: String? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ProxyConfig#proxy_url. +// documentation +// > Optional proxy URL. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Comma-separated string that can contain IPs, CIDR notation, domain names + /// that should be excluded from proxying. IP and domain names can + /// contain port numbers. + no_proxy: String? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ProxyConfig#no_proxy. +// documentation +// > Comma-separated string that can contain IPs, CIDR notation, domain names +// > that should be excluded from proxying. IP and domain names can +// > contain port numbers. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Use proxy URL indicated by environment variables + /// (HTTP_PROXY, https_proxy, HTTPs_PROXY, https_proxy, and no_proxy) + proxy_from_environment: Boolean? +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ProxyConfig#proxy_from_environment. +// documentation +// > Use proxy URL indicated by environment variables +// > (HTTP_PROXY, https_proxy, HTTPs_PROXY, https_proxy, and no_proxy) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Specifies headers to send to proxies during CONNECT requests. + proxy_connect_haeder: Mapping>? +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ProxyConfig#proxy_connect_haeder. +// documentation +// > Specifies headers to send to proxies during CONNECT requests. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + abstract class HttpClientConfig extends ProxyConfig { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ProxyConfig# + /// Sets the `Authorization` header on every request + /// with the configured username and password. + basic_auth: BasicAuth?(atMostOneSet(List(this, authorization, oauth2, bearer_token, bearer_token_file))) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#basic_auth. +// documentation +// > Sets the `Authorization` header on every request +// > with the configured username and password. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/BasicAuth# +// ^^^^^^^^^^^^ reference local atMostOneSet_797 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#authorization. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#oauth2. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#bearer_token. +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#bearer_token_file. + + /// Sets the `Authorization` header on every scrape request with the configured bearer token. + /// + /// Mutually exclusive with [bearer_token_file]. + @Deprecated { message = "Deprecated in favor of [Authorization.credentials]" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Deprecated# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#message. + bearer_token: String? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#bearer_token. +// documentation +// > Sets the `Authorization` header on every scrape request with the configured bearer token. +// > +// > Mutually exclusive with [`bearer_token_file`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L683,C3). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Sets the `Authorization` header on every scrape request + /// with the bearer token read from the configured file. + /// + /// Mutually exclusive with [bearer_token]. + @Deprecated { message = "Deprecated in favor of [Authorization.credentials_file]" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Deprecated# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#message. + bearer_token_file: String? +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#bearer_token_file. +// documentation +// > Sets the `Authorization` header on every scrape request +// > with the bearer token read from the configured file. +// > +// > Mutually exclusive with [`bearer_token`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L676,C3). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Sets the `Authorization` header on every request with the configured credentials. + authorization: Authorization? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#authorization. +// documentation +// > Sets the `Authorization` header on every request with the configured credentials. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Authorization# + + /// Optional OAuth 2.0 configuration. + /// Cannot be used at the same time as basic_auth or authorization. + oauth2: OAuth2? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#oauth2. +// documentation +// > Optional OAuth 2.0 configuration. +// > Cannot be used at the same time as basic_auth or authorization. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/OAuth2# + + /// Configures the remote read request's TLS settings. + tls_config: TLSConfig? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#tls_config. +// documentation +// > Configures the remote read request's TLS settings. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig# + + /// Configure whether scrape requests follow HTTP 3xx redirects. + /// + /// Defaults to [true] + follow_redirects: Boolean? +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#follow_redirects. +// documentation +// > Configure whether scrape requests follow HTTP 3xx redirects. +// > +// > Defaults to `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Whether to enable HTTP2. + /// + /// Defaults to [true] + enable_http2: Boolean? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/HttpClientConfig#enable_http2. +// documentation +// > Whether to enable HTTP2. +// > +// > Defaults to `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + class BasicAuth { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/BasicAuth# + username: String(username_file == null)? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/BasicAuth#username. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/BasicAuth#username_file. + + username_file: String? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/BasicAuth#username_file. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Mutually exclusive with [password_file]. + password: String(password_file == null)? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/BasicAuth#password. +// documentation +// > Mutually exclusive with [`password_file`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L715,C3). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/BasicAuth#password_file. + + /// Mutually exclusive with [password]. + password_file: String? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/BasicAuth#password_file. +// documentation +// > Mutually exclusive with [`password`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Configuration.pkl#L712,C3). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + class Authorization { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Authorization# + /// Sets the authentication type. + /// + /// Defaults to `"Bearer"` + type: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Authorization#type. +// documentation +// > Sets the authentication type. +// > +// > Defaults to `"Bearer"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Sets the credentals. + credentials: String(credentials_file == null)? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Authorization#credentials. +// documentation +// > Sets the credentals. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Authorization#credentials_file. + + /// Sets the credentals to read from the configured file. + credentials_file: String? +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/Authorization#credentials_file. +// documentation +// > Sets the credentals to read from the configured file. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + class OAuth2 extends ProxyConfig { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/OAuth2# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/ProxyConfig# + /// Sets the OAuth2 client ID. + client_id: String +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/OAuth2#client_id. +// documentation +// > Sets the OAuth2 client ID. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Sets the OAuth2 client secret. + client_secret: String(client_secret_file == null)? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/OAuth2#client_secret. +// documentation +// > Sets the OAuth2 client secret. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/OAuth2#client_secret_file. + + /// Read the OAuth2 client secret from a file. + client_secret_file: String? +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/OAuth2#client_secret_file. +// documentation +// > Read the OAuth2 client secret from a file. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Scopes for the token request. + scopes: Listing? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/OAuth2#scopes. +// documentation +// > Scopes for the token request. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The URL to fetch the token from + token_url: String +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/OAuth2#token_url. +// documentation +// > The URL to fetch the token from +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Optional parameters to append to the token URL. + endpoint_params: Mapping +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/OAuth2#endpoint_params. +// documentation +// > Optional parameters to append to the token URL. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Configures the token request's TLS settings + tls_config: TLSConfig? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/OAuth2#tls_config. +// documentation +// > Configures the token request's TLS settings +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig# + } + + /// Allows configuring TLS connections. + class TLSConfig { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig# +// documentation +// > Allows configuring TLS connections. + /// CA certificate to validate API server certificate with. + ca: String(ca_file == null)? +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#ca. +// documentation +// > CA certificate to validate API server certificate with. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#ca_file. + + /// Certificate for client cert authentication to the server. + cert: String(cert_file == null)? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#cert. +// documentation +// > Certificate for client cert authentication to the server. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#cert_file. + + /// Key for client cert authentication to the server. + key: String(key_file == null)? +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#key. +// documentation +// > Key for client cert authentication to the server. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#key_file. + + /// CA certificate file to validate API server certificate with. + ca_file: String? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#ca_file. +// documentation +// > CA certificate file to validate API server certificate with. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Certificate file for client cert authentication to the server. + cert_file: String? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#cert_file. +// documentation +// > Certificate file for client cert authentication to the server. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Key file for client cert authentication to the server. + key_file: String? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#key_file. +// documentation +// > Key file for client cert authentication to the server. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// ServerName extension to indicate the name of the server. + /// + /// + server_name: String? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#server_name. +// documentation +// > ServerName extension to indicate the name of the server. +// > +// > +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Disable validation of the server certificate. + insecure_skip_verify: Boolean? +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#insecure_skip_verify. +// documentation +// > Disable validation of the server certificate. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Minimum acceptable TLS version + /// + /// If unset, Prometheus will use Go default minimum version, which is TLS 1.2. + /// See MinVersion in . + min_version: TLSVersion? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#min_version. +// documentation +// > Minimum acceptable TLS version +// > +// > If unset, Prometheus will use Go default minimum version, which is TLS 1.2. +// > See MinVersion in . +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSVersion# + + /// Maximum acceptable TLS version. + /// + /// If unset, Prometheus will use Go default maximum version, which is TLS 1.3. + /// See MaxVersion in . + max_version: TLSVersion? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSConfig#max_version. +// documentation +// > Maximum acceptable TLS version. +// > +// > If unset, Prometheus will use Go default maximum version, which is TLS 1.3. +// > See MaxVersion in . +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSVersion# + } + + typealias TLSVersion = "TLS10"|"TLS11"|"TLS12"|"TLS13" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Configuration.pkl`/TLSVersion# + + /// Tells if only one of the values is not null. + local const function atMostOneSet(values: List): Boolean = +// ^^^^^^^^^^^^ definition local atMostOneSet_797 +// documentation +// > Tells if only one of the values is not null. +// ^^^^^^ definition local values_798 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + values.filterNonNull().length <= 1 +// ^^^^^^ reference local values_798 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. + diff --git a/pkl-pantrysnapshot/io.prometheus/PklProject b/pkl-pantrysnapshot/io.prometheus/PklProject new file mode 100755 index 00000000..a18b26f8 --- /dev/null +++ b/pkl-pantrysnapshot/io.prometheus/PklProject @@ -0,0 +1,25 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Templates for configuring [Prometheus](https://prometheus.io), + /// an open-source systems monitoring and alerting toolkit. + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 PklProject/package. + version = "1.4.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/io.prometheus/PrometheusObject.pkl b/pkl-pantrysnapshot/io.prometheus/PrometheusObject.pkl new file mode 100755 index 00000000..fd4205d3 --- /dev/null +++ b/pkl-pantrysnapshot/io.prometheus/PrometheusObject.pkl @@ -0,0 +1,91 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Base module for Prometheus configuration objects + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/minPklVersion. + abstract module io.prometheus.PrometheusObject +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/ + + typealias MetricNameFormat = String(matches(Regex(#"[a-zA-Z_:][a-zA-Z0-9_:]*"#))) +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/MetricNameFormat# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + + typealias LabelNameFormat = String(matches(Regex(#"[a-zA-Z_][a-zA-Z0-9_]*"#))) +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/LabelNameFormat# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + + typealias Labels = Mapping +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Labels# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/LabelNameFormat# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + typealias Scheme = *"http"|"https" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Scheme# + + local function convertDuration(dur: Duration) = +// ^^^^^^^^^^^^^^^ definition local convertDuration_28 +// ^^^ definition local dur_28 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + if (dur.unit == "min") dur.value.toString() + "m" +// ^^^ reference local dur_28 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#unit. +// ^^^ reference local dur_28 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#value. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#toString(). + else if (dur.unit == "ns") convertDuration(dur.toUnit("ms")) +// ^^^ reference local dur_28 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#unit. +// ^^^^^^^^^^^^^^^ reference local convertDuration_28 +// ^^^ reference local dur_28 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#toUnit(). + else if (dur.unit == "us") convertDuration(dur.toUnit("ms")) +// ^^^ reference local dur_28 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#unit. +// ^^^^^^^^^^^^^^^ reference local convertDuration_28 +// ^^^ reference local dur_28 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#toUnit(). + else dur.value.toString() + dur.unit +// ^^^ reference local dur_28 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#value. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#toString(). +// ^^^ reference local dur_28 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#unit. + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/output. + renderer = new YamlRenderer { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/renderer. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/YamlRenderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/converters. + [Duration] = (dur: Duration) -> convertDuration(dur) +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# +// ^^^ definition local dur_37 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# +// ^^^^^^^^^^^^^^^ reference local convertDuration_28 +// ^^^ reference local dur_37 + } + } + } + diff --git a/pkl-pantrysnapshot/io.prometheus/Rule.pkl b/pkl-pantrysnapshot/io.prometheus/Rule.pkl new file mode 100755 index 00000000..790f460b --- /dev/null +++ b/pkl-pantrysnapshot/io.prometheus/Rule.pkl @@ -0,0 +1,275 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Prometheus supports two types of rules which may be configured + /// and then evaluated at regular intervals: recording rules and alerting rules. + /// + /// To include rules in Prometheus, create a file containing the necessary rule statements + /// and have Prometheus load the file via [Configuration.rule_files]. + /// + /// The rule files can be reloaded at runtime by sending `SIGHUP` to the Prometheus process. + /// The changes are only applied if all rule files are well-formatted. + /// + /// More details: + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/minPklVersion. + open module io.prometheus.Rule +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/ + + extends "PrometheusObject.pkl" + + import "Configuration.pkl" + + groups: Listing? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/groups. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RuleGroup# + + typealias RuleGroup = *AlertingRuleGroup|RecordingRuleGroup +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RuleGroup# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRuleGroup# +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRuleGroup# + + class RecordingRuleGroup { +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRuleGroup# + /// The name of the group. Must be unique within a file. + name: MetricNameFormat +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRuleGroup#name. +// documentation +// > The name of the group. Must be unique within a file. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/MetricNameFormat# + + /// How often rules in the group are evaluated. + interval: Duration? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRuleGroup#interval. +// documentation +// > How often rules in the group are evaluated. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Thanos Ruler's partial response behavior + partial_response_strategy: String? +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRuleGroup#partial_response_strategy. +// documentation +// > Thanos Ruler's partial response behavior +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Limit the number of alerts an alerting rule and series a recording rule can produce. + limit: Int? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRuleGroup#limit. +// documentation +// > Limit the number of alerts an alerting rule and series a recording rule can produce. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Labels to add or overwrite before storing the result for its rules. + /// + /// Labels defined in [RecordingRule] will override the key if it has a collision. + labels: Labels? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRuleGroup#labels. +// documentation +// > Labels to add or overwrite before storing the result for its rules. +// > +// > Labels defined in [`RecordingRule`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Rule.pkl#L128,C7) will override the key if it has a collision. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Labels# + + rules: Listing +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRuleGroup#rules. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRule# + } + + class AlertingRuleGroup { +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRuleGroup# + /// The name of the group. Must be unique within a file. + name: LabelNameFormat +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRuleGroup#name. +// documentation +// > The name of the group. Must be unique within a file. +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/LabelNameFormat# + + /// How often rules in the group are evaluated. + interval: Duration? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRuleGroup#interval. +// documentation +// > How often rules in the group are evaluated. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Thanos Ruler's partial response behavior + partial_response_strategy: String? +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRuleGroup#partial_response_strategy. +// documentation +// > Thanos Ruler's partial response behavior +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Limit the number of alerts an alerting rule and series a recording rule can produce. + limit: Int? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRuleGroup#limit. +// documentation +// > Limit the number of alerts an alerting rule and series a recording rule can produce. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Labels to add or overwrite before storing the result for its rules. + /// + /// Labels defined in [AlertingRule] will override the key if it has a collision. + labels: Labels? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRuleGroup#labels. +// documentation +// > Labels to add or overwrite before storing the result for its rules. +// > +// > Labels defined in [`AlertingRule`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/io.prometheus/Rule.pkl#L87,C7) will override the key if it has a collision. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Labels# + + rules: Listing +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRuleGroup#rules. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRule# + } + + /// Alerting rules allow you to define alert conditions + /// based on Prometheus expression language expressions + /// and to send notifications about firing alerts to an external service. + /// + /// Whenever the alert expression results in one or more vector elements at a given point in time, + /// the alert counts as active for these elements' label sets. + /// + /// More details: + class AlertingRule { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRule# +// documentation +// > Alerting rules allow you to define alert conditions +// > based on Prometheus expression language expressions +// > and to send notifications about firing alerts to an external service. +// > +// > Whenever the alert expression results in one or more vector elements at a given point in time, +// > the alert counts as active for these elements' label sets. +// > +// > More details: + /// The name of the alert. Must be a valid label value. + alert: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRule#alert. +// documentation +// > The name of the alert. Must be a valid label value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The PromQL expression to evaluate. + /// + /// Every evaluation cycle this is evaluated at the current time, + /// and all resultant time series become pending/firing alerts. + expr: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRule#expr. +// documentation +// > The PromQL expression to evaluate. +// > +// > Every evaluation cycle this is evaluated at the current time, +// > and all resultant time series become pending/firing alerts. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Alerts are considered firing once they have been returned for this long. + /// + /// Alerts which have not yet fired for long enough are considered pending. + /// + /// Default if omitted: `0.s` + `for`: Duration? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRule#for. +// documentation +// > Alerts are considered firing once they have been returned for this long. +// > +// > Alerts which have not yet fired for long enough are considered pending. +// > +// > Default if omitted: `0.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Labels to add or overwrite for each alert. + labels: Labels? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRule#labels. +// documentation +// > Labels to add or overwrite for each alert. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Labels# + + /// Annotations to add to each alert. + annotations: Mapping? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRule#annotations. +// documentation +// > Annotations to add to each alert. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// Recording rules allow you to precompute frequently needed or computationally + /// expensive expressions and save their result as a new set of time series. + /// + /// Querying the precomputed result will then often be much faster + /// than executing the original expression every time it is needed. + /// This is especially useful for dashboards, + /// which need to query the same expression repeatedly every time they refresh. + /// + /// Recording and alerting rules exist in a rule group. + /// Rules within a group are run sequentially at a regular interval, + /// with the same evaluation time. + /// The names of recording rules must be + /// [valid metric names](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). + /// The names of alerting rules must be + /// [valid label values](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). + /// + /// More details: + class RecordingRule { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRule# +// documentation +// > Recording rules allow you to precompute frequently needed or computationally +// > expensive expressions and save their result as a new set of time series. +// > +// > Querying the precomputed result will then often be much faster +// > than executing the original expression every time it is needed. +// > This is especially useful for dashboards, +// > which need to query the same expression repeatedly every time they refresh. +// > +// > Recording and alerting rules exist in a rule group. +// > Rules within a group are run sequentially at a regular interval, +// > with the same evaluation time. +// > The names of recording rules must be +// > [valid metric names](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). +// > The names of alerting rules must be +// > [valid label values](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). +// > +// > More details: + /// The name of the time series to output to. Must be a valid metric name. + `record`: String +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRule#record. +// documentation +// > The name of the time series to output to. Must be a valid metric name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The PromQL expression to evaluate. + /// + /// Every evaluation cycle this is evaluated at the current time, + /// and the result recorded as a new set of time series with the metric name as given by 'record'. + expr: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRule#expr. +// documentation +// > The PromQL expression to evaluate. +// > +// > Every evaluation cycle this is evaluated at the current time, +// > and the result recorded as a new set of time series with the metric name as given by 'record'. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Labels to add or overwrite before storing the result. + labels: Labels? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRule#labels. +// documentation +// > Labels to add or overwrite before storing the result. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `PrometheusObject.pkl`/Labels# + } + diff --git a/pkl-pantrysnapshot/io.prometheus/examples/configuration.pkl b/pkl-pantrysnapshot/io.prometheus/examples/configuration.pkl new file mode 100755 index 00000000..13fd9462 --- /dev/null +++ b/pkl-pantrysnapshot/io.prometheus/examples/configuration.pkl @@ -0,0 +1,62 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module io.prometheus.examples.configuration +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/ + + amends "../Configuration.pkl" + + global { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/global. + scrape_timeout = 10.s +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/scrape_timeout. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#s. + } + + scrape_configs { +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/scrape_configs. + new { + job_name = "my-job" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/job_name. + kubernetes_sd_configs { +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/kubernetes_sd_configs. + new { + role = "pod" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/role. + } + } + relabel_configs { +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/relabel_configs. + new { + regex = ".*?" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/regex. + } + } + } + } + + remote_write { +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/remote_write. + new { + url = "https://example.com/remote_write" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/url. + sigv4 { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/sigv4. + region = "us-west-2" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/configuration.pkl`/region. + } + } + } + diff --git a/pkl-pantrysnapshot/io.prometheus/examples/rule.pkl b/pkl-pantrysnapshot/io.prometheus/examples/rule.pkl new file mode 100755 index 00000000..a69d122b --- /dev/null +++ b/pkl-pantrysnapshot/io.prometheus/examples/rule.pkl @@ -0,0 +1,79 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module io.prometheus.examples.rule +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/ + + amends "../Rule.pkl" + + groups { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/groups. + new AlertingRuleGroup { +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/AlertingRuleGroup# + name = "alerting_rules" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/name. + interval = 5.min +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/interval. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#min. + labels { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/labels. + ["group"] = "alerts" + } + rules { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/rules. + new { + alert = "HighRequestLatency" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/alert. + expr = #"job:request_latency_seconds:mean5m{job="myjob"} > 0.5"# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/expr. + `for` = 10.min +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/for. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#min. + labels { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/labels. + ["prod"] = true + ["priority"] = 1 + ["severity"] = "page" + } + annotations { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/annotations. + ["summary"] = "High request latency" + } + } + } + } + new RecordingRuleGroup { +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `Rule.pkl`/RecordingRuleGroup# + name = "recording_rules" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/name. + interval = 10.h +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/interval. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#h. + labels { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/labels. + ["group"] = "recording" + } + rules { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/rules. + new { + `record` = "job:http_inprogress_requests:sum" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/record. + expr = "sum by (job) (http_inprogress_requests)" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `examples/rule.pkl`/expr. + } + } + } + } + diff --git a/pkl-pantrysnapshot/io.prometheus/tests/configuration.pkl b/pkl-pantrysnapshot/io.prometheus/tests/configuration.pkl new file mode 100755 index 00000000..18a62327 --- /dev/null +++ b/pkl-pantrysnapshot/io.prometheus/tests/configuration.pkl @@ -0,0 +1,29 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module io.prometheus.tests.configuration +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `tests/configuration.pkl`/ + + amends "pkl:test" + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `tests/configuration.pkl`/examples. + ["basic configuration"] { + import("../examples/configuration.pkl").output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + diff --git a/pkl-pantrysnapshot/io.prometheus/tests/rule.pkl b/pkl-pantrysnapshot/io.prometheus/tests/rule.pkl new file mode 100755 index 00000000..9d7d5bdc --- /dev/null +++ b/pkl-pantrysnapshot/io.prometheus/tests/rule.pkl @@ -0,0 +1,29 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module io.prometheus.tests.rule +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `tests/rule.pkl`/ + + amends "pkl:test" + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/io.prometheus 1.4.0 `tests/rule.pkl`/examples. + ["basic rule"] { + import("../examples/rule.pkl").output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + diff --git a/pkl-pantrysnapshot/k8s.contrib.appEnvCluster/AppEnvCluster.pkl b/pkl-pantrysnapshot/k8s.contrib.appEnvCluster/AppEnvCluster.pkl new file mode 100755 index 00000000..a3c73516 --- /dev/null +++ b/pkl-pantrysnapshot/k8s.contrib.appEnvCluster/AppEnvCluster.pkl @@ -0,0 +1,484 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Template for generating Kubernetes manifests for apps. + /// + /// This template assumes a three-level configuration hierarchy: application, environment, and cluster. + /// Modules at the root of the configuration hierarchy directly amend this module + /// (`amends "package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster@#/AppEnvCluster.pkl"`). + /// All other modules amend their parent (`amends "..."`). + /// + /// Leaf modules dictate which Kubernetes resources are generated. + /// To generate all resources, evaluate all modules (non-leaf modules are automatically ignored): + /// + /// ```bash + /// $ pkl eval **/*.pkl + /// ``` + /// + /// By default, all resources are written to standard output as a YAML stream, where each resource + /// is separated using `---`. + /// This YAML stream may also be written to a file using the + /// [`-o`](https://pkl-lang.org/main/current/pkl-cli/index.html#output-path) flag. + /// + /// Each resource can also be written to its own file using the + /// [`-m`](https://pkl-lang.org/main/current/pkl-cli/index.html#multiple-file-output-path) flag. + /// When writing individual files, the file paths follow the same three-level hierarchy of + /// application, environment and cluster. + /// + /// ```bash + /// # Write all resources as a YAML stream into `output.yaml` + /// $ pkl eval -o output.yaml **/*.pkl + /// + /// # Write each resource to its own file to the `.out/` directory + /// $ pkl eval -m .out/ **/*.pkl + /// ``` + /// + /// Modules higher up in the config hierarchy contain configuration common to their descendants. + /// + /// Kubernetes resources are grouped by kind and keyed by name: + /// + /// ```pkl + /// ingresses { + /// ["cluster-service.example.com"] { ... } + /// } + /// services { + /// ["cluster-service"] { ... } + /// } + /// ``` + /// + /// Resource names are used as default values for the resources' `metadata.name` properties. + /// + /// Kubernetes configuration often contains lists of key-value pairs. + /// To override a particular value, match its key with a _predicate_: + /// + /// ```pkl + /// env { // list of environment variable names and values + /// [[name == "IMAGE_REPOSITORY"]] { // override value(s) matching this predicate + /// value = "docker.com" + /// } + /// } + /// ``` + /// + /// Note the use of double brackets (`[[...]]`), which distinguishes a predicate from an ordinary key (`[...]`). + /// + /// == Extending This Template + /// + /// This template only covers the most common kinds of resources: [configMaps], [deployments], [ingresses], etc. + /// To describe other kinds of resources, _extend_ this template and add additional top-level properties. + /// For example, to describe _HorizontalPodAutoscaler_ resources, + /// create a new file named `MyTemplate.pkl` with the following content: + /// + /// ```pkl + /// module MyTemplate + /// + /// extends "package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster@#/AppEnvCluster.pkl" + /// + /// import "package://pkg.pkl-lang.org/pkl-k8s/k8s@#/api/autoscaling/v1/HorizontalPodAutoscaler.pkl" + /// + /// horizontalPodAutoscalers: Mapping = module.resourceMapping(HorizontalPodAutoscaler) + /// ``` + /// + /// To browse Pkl Kubernetes templates and determine their import URIs (such as `package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.0#/api/core/v1/Pod.pkl`), + /// go to [the package repo](https://pkl-lang.org/package-docs/pkg.pkl-lang.org/pkl-k8s/k8s/current/). + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/minPklVersion. + open module k8s.contrib.appEnvCluster.AppEnvCluster +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/ + + import "pkl:reflect" + import "@k8s/K8sObject.pkl" + import "@k8s/K8sResource.pkl" + import "@k8s/api/apps/v1/Deployment.pkl" + import "@k8s/api/apps/v1/StatefulSet.pkl" + import "@k8s/api/core/v1/ConfigMap.pkl" + import "@k8s/api/core/v1/PersistentVolumeClaim.pkl" + import "@k8s/api/core/v1/Pod.pkl" + import "@k8s/api/core/v1/Secret.pkl" + import "@k8s/api/core/v1/Service.pkl" + import "@k8s/api/networking/v1/Ingress.pkl" + import "@k8s/apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl" + + /// Kubernetes resources of type [ConfigMap], keyed by name. + /// + /// The resources' `metadata.name` property is automatically set to their key. + configMaps: Mapping = resourceMapping(ConfigMap) +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/configMaps. +//documentation +//> Kubernetes resources of type [`ConfigMap`](pkl-lsp://jar/jar%3Afile%3A%2F%2F%2FUsers%2Fthomas%2F.pkl%2Fcache%2Fpackage-2%2Fpkg.pkl-lang.org%2Fpkl-k8s%2Fk8s%401.0.1%2Fk8s%401.0.1.zip%21%2Fapi%2Fcore%2Fv1%2FConfigMap.pkl#L19,C1), keyed by name. +//> +//> The resources' `metadata.name` property is automatically set to their key. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/core/v1/ConfigMap.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/resourceMapping(). +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/core/v1/ConfigMap.pkl`/ + + /// Kubernetes resources of type [Deployment], keyed by name. + /// + /// The resources' `metadata.name` property is automatically set to their key. + deployments: Mapping = resourceMapping(Deployment) +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/deployments. +//documentation +//> Kubernetes resources of type [`Deployment`](pkl-lsp://jar/jar%3Afile%3A%2F%2F%2FUsers%2Fthomas%2F.pkl%2Fcache%2Fpackage-2%2Fpkg.pkl-lang.org%2Fpkl-k8s%2Fk8s%401.0.1%2Fk8s%401.0.1.zip%21%2Fapi%2Fapps%2Fv1%2FDeployment.pkl#L19,C1), keyed by name. +//> +//> The resources' `metadata.name` property is automatically set to their key. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/apps/v1/Deployment.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/resourceMapping(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/apps/v1/Deployment.pkl`/ + + /// Kubernetes resources of type [Ingress], keyed by name. + /// + /// The resources' `metadata.name` property is automatically set to their key. + ingresses: Mapping = resourceMapping(Ingress) +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/ingresses. +//documentation +//> Kubernetes resources of type [`Ingress`](pkl-lsp://jar/jar%3Afile%3A%2F%2F%2FUsers%2Fthomas%2F.pkl%2Fcache%2Fpackage-2%2Fpkg.pkl-lang.org%2Fpkl-k8s%2Fk8s%401.0.1%2Fk8s%401.0.1.zip%21%2Fapi%2Fnetworking%2Fv1%2FIngress.pkl#L21,C1), keyed by name. +//> +//> The resources' `metadata.name` property is automatically set to their key. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/networking/v1/Ingress.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/resourceMapping(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/networking/v1/Ingress.pkl`/ + + /// Kubernetes resources of type [PersistentVolumeClaim], keyed by name. + /// + /// The resources' `metadata.name` property is automatically set to their key. + persistentVolumeClaims: Mapping = resourceMapping(PersistentVolumeClaim) +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/persistentVolumeClaims. +//documentation +//> Kubernetes resources of type [`PersistentVolumeClaim`](pkl-lsp://jar/jar%3Afile%3A%2F%2F%2FUsers%2Fthomas%2F.pkl%2Fcache%2Fpackage-2%2Fpkg.pkl-lang.org%2Fpkl-k8s%2Fk8s%401.0.1%2Fk8s%401.0.1.zip%21%2Fapi%2Fcore%2Fv1%2FPersistentVolumeClaim.pkl#L19,C1), keyed by name. +//> +//> The resources' `metadata.name` property is automatically set to their key. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/core/v1/PersistentVolumeClaim.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/resourceMapping(). +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/core/v1/PersistentVolumeClaim.pkl`/ + + /// Kubernetes resources of type [Pod], keyed by name. + /// + /// The resources' `metadata.name` property is automatically set to their key. + pods: Mapping = resourceMapping(Pod) +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/pods. +//documentation +//> Kubernetes resources of type [`Pod`](pkl-lsp://jar/jar%3Afile%3A%2F%2F%2FUsers%2Fthomas%2F.pkl%2Fcache%2Fpackage-2%2Fpkg.pkl-lang.org%2Fpkl-k8s%2Fk8s%401.0.1%2Fk8s%401.0.1.zip%21%2Fapi%2Fcore%2Fv1%2FPod.pkl#L21,C1), keyed by name. +//> +//> The resources' `metadata.name` property is automatically set to their key. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/core/v1/Pod.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/resourceMapping(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/core/v1/Pod.pkl`/ + + /// Kubernetes resources of type [Secret], keyed by name. + /// + /// The resources' `metadata.name` property is automatically set to their key. + secrets: Mapping = resourceMapping(Secret) +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/secrets. +//documentation +//> Kubernetes resources of type [`Secret`](pkl-lsp://jar/jar%3Afile%3A%2F%2F%2FUsers%2Fthomas%2F.pkl%2Fcache%2Fpackage-2%2Fpkg.pkl-lang.org%2Fpkl-k8s%2Fk8s%401.0.1%2Fk8s%401.0.1.zip%21%2Fapi%2Fcore%2Fv1%2FSecret.pkl#L21,C1), keyed by name. +//> +//> The resources' `metadata.name` property is automatically set to their key. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/core/v1/Secret.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/resourceMapping(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/core/v1/Secret.pkl`/ + + /// Kubernetes resources of type [Service], keyed by name. + /// + /// The resources' `metadata.name` property is automatically set to their key. + services: Mapping = resourceMapping(Service) +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/services. +//documentation +//> Kubernetes resources of type [`Service`](pkl-lsp://jar/jar%3Afile%3A%2F%2F%2FUsers%2Fthomas%2F.pkl%2Fcache%2Fpackage-2%2Fpkg.pkl-lang.org%2Fpkl-k8s%2Fk8s%401.0.1%2Fk8s%401.0.1.zip%21%2Fapi%2Fcore%2Fv1%2FService.pkl#L19,C1), keyed by name. +//> +//> The resources' `metadata.name` property is automatically set to their key. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/core/v1/Service.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/resourceMapping(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/core/v1/Service.pkl`/ + + /// Kubernetes resources of type [StatefulSet], keyed by name. + /// + /// The resources' `metadata.name` property is automatically set to their key. + statefulSets: Mapping = resourceMapping(StatefulSet) +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/statefulSets. +//documentation +//> Kubernetes resources of type [`StatefulSet`](pkl-lsp://jar/jar%3Afile%3A%2F%2F%2FUsers%2Fthomas%2F.pkl%2Fcache%2Fpackage-2%2Fpkg.pkl-lang.org%2Fpkl-k8s%2Fk8s%401.0.1%2Fk8s%401.0.1.zip%21%2Fapi%2Fapps%2Fv1%2FStatefulSet.pkl#L25,C1), keyed by name. +//> +//> The resources' `metadata.name` property is automatically set to their key. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/apps/v1/StatefulSet.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/resourceMapping(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/apps/v1/StatefulSet.pkl`/ + + /// The application that [resources] belong to. + /// + /// This is the first level of the application/environment/cluster directory structure. + /// To access this property from a module that amends this template, use `module.app`. + hidden app: String = path[0] +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/app. +// documentation +// > The application that `resources` belong to. +// > +// > This is the first level of the application/environment/cluster directory structure. +// > To access this property from a module that amends this template, use `module.app`. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/path. + + /// The environment that [resources] belong to. + /// + /// This is the second level of the application/environment/cluster directory structure. + /// To access this property from a module that amends this template, use `module.env`. + hidden env: String = path[1] +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/env. +// documentation +// > The environment that `resources` belong to. +// > +// > This is the second level of the application/environment/cluster directory structure. +// > To access this property from a module that amends this template, use `module.env`. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/path. + + /// The cluster that [resources] belong to. + /// + /// This is the third level of the application/environment/cluster directory structure. + /// To access this property from a module that amends this template, use `module.cluster`. + hidden cluster: String = path[2] +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/cluster. +// documentation +// > The cluster that `resources` belong to. +// > +// > This is the third level of the application/environment/cluster directory structure. +// > To access this property from a module that amends this template, use `module.cluster`. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/path. + + /// File path between the current module ([this]) and its template, relative to the template. + /// + /// Does not include the current module's file name. + hidden path: List = findRootModule(reflect.Module(module)).relativePathTo(module) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/path. +// documentation +// > File path between the current module (`this`) and its template, relative to the template. +// > +// > Does not include the current module's file name. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^ reference local findRootModule_201 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module(). +// ^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#relativePathTo(). + + /// Renders a Pkl object as YAML string. + /// + /// With this method, YAML files in [ConfigMap]s can be specified as Pkl objects rather than strings. + function toYamlString(obj: Object): String = output.renderer.renderValue(obj) +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/toYamlString(). +// documentation +// > Renders a Pkl object as YAML string. +// > +// > With this method, YAML files in [`ConfigMap`](pkl-lsp://jar/jar%3Afile%3A%2F%2F%2FUsers%2Fthomas%2F.pkl%2Fcache%2Fpackage-2%2Fpkg.pkl-lang.org%2Fpkl-k8s%2Fk8s%401.0.1%2Fk8s%401.0.1.zip%21%2Fapi%2Fcore%2Fv1%2FConfigMap.pkl#L19,C1)s can be specified as Pkl objects rather than strings. +// ^^^ definition local obj_177 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Object# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/output. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#renderer. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer#renderValue(). +// ^^^ reference local obj_177 + + /// Creates an empty mapping from resource name to resource [type] that defaults `metadata.name` to the resource name. + function resourceMapping(type): Mapping = +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/resourceMapping(). +// documentation +// > Creates an empty mapping from resource name to resource [`type`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/k8s.contrib.appEnvCluster/AppEnvCluster.pkl#L180,C26) that defaults `metadata.name` to the resource name. +// ^^^^ definition local type_180 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + new Mapping { default = (key) -> (type) { metadata { name = key } } } +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/default. +// ^^^ definition local key_181 +// ^^^^ reference local type_180 +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/metadata. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/name. +// ^^^ reference local key_181 + + /// Tells if the current module ([this]) is a leaf module. Only leaf modules generate output. + /// + /// Override this method to extend the application/environment/cluster directory structure beyond three levels. + function isLeafModule(): Boolean = path.length == 3 +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/isLeafModule(). +// documentation +// > Tells if the current module (`this`) is a leaf module. Only leaf modules generate output. +// > +// > Override this method to extend the application/environment/cluster directory structure beyond three levels. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/path. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/output. + renderer = new YamlRenderer { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/renderer. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/YamlRenderer# + isStream = true +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/isStream. + converters = (K8sObject.output.renderer as YamlRenderer).converters +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/converters. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `K8sObject.pkl`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#renderer. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/YamlRenderer# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer#converters. + } + value = if (isLeafModule()) module.toMap().values.flatMap((it) -> it.toMap().values) else List() +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/value. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/isLeafModule(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#flatMap(). +// ^^ definition local it_193 +// ^^ reference local it_193 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + files { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/files. + for (file: K8sResource in value as List) { +// ^^^^ definition local file_195 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `K8sResource.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/value. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# + [determineFileName(file)] = file.output +// ^^^^^^^^^^^^^^^^^ reference local determineFileName_218 +// ^^^^ reference local file_195 +// ^^^^ reference local file_195 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. + } + } + } + + local function findRootModule(mod: reflect.Module): Module = +// ^^^^^^^^^^^^^^ definition local findRootModule_201 +// ^^^ definition local mod_201 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module# + let (supermodule = mod.supermodule) +// ^^^^^^^^^^^ definition local supermodule_202 +// ^^^ reference local mod_201 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#supermodule. + if (supermodule == null || !supermodule.isAmend) mod.reflectee +// ^^^^^^^^^^^ reference local supermodule_202 +// ^^^^^^^^^^^ reference local supermodule_202 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#isAmend. +// ^^^ reference local mod_201 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#reflectee. + else findRootModule(supermodule) +// ^^^^^^^^^^^^^^ reference local findRootModule_201 +// ^^^^^^^^^^^ reference local supermodule_202 + + local class GroupVersion { +// ^^^^^^^^^^^^ definition local GroupVersion_206 + group: String? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/GroupVersion#group. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + version: String +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/GroupVersion#version. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + local function parseGroupVersion(apiVersionString: String): GroupVersion = +// ^^^^^^^^^^^^^^^^^ definition local parseGroupVersion_211 +// ^^^^^^^^^^^^^^^^ definition local apiVersionString_211 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^ reference local GroupVersion_206 + let (idx = apiVersionString.indexOfOrNull("/")) +// ^^^ definition local idx_212 +// ^^^^^^^^^^^^^^^^ reference local apiVersionString_211 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#indexOfOrNull(). + if (idx == null) +// ^^^ reference local idx_212 + new { version = apiVersionString } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/version. +// ^^^^^^^^^^^^^^^^ reference local apiVersionString_211 + else + new { group = apiVersionString.take(idx); version = apiVersionString.drop(idx + 1) } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/group. +// ^^^^^^^^^^^^^^^^ reference local apiVersionString_211 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#take(). +// ^^^ reference local idx_212 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/version. +// ^^^^^^^^^^^^^^^^ reference local apiVersionString_211 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^^ reference local idx_212 + + local function determineFileName(resource: K8sResource) = +// ^^^^^^^^^^^^^^^^^ definition local determineFileName_218 +// ^^^^^^^^ definition local resource_218 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `K8sResource.pkl`/ + let (metadata = resource.getPropertyOrNull("metadata") as ObjectMeta?) +// ^^^^^^^^ definition local metadata_219 +// ^^^^^^^^ reference local resource_218 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#getPropertyOrNull(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl`/ + let (groupVersion = parseGroupVersion(resource.apiVersion)) +// ^^^^^^^^^^^^ definition local groupVersion_220 +// ^^^^^^^^^^^^^^^^^ reference local parseGroupVersion_211 +// ^^^^^^^^ reference local resource_218 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `K8sResource.pkl`/apiVersion. + let (dir = path.join("/")) +// ^^^ definition local dir_221 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/path. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + let (baseName = +// ^^^^^^^^ definition local baseName_222 + List( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + metadata?.namespace, +// ^^^^^^^^ reference local metadata_219 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl`/namespace. + metadata?.name, +// ^^^^^^^^ reference local metadata_219 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl`/name. + groupVersion.group, +// ^^^^^^^^^^^^ reference local groupVersion_220 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 `AppEnvCluster.pkl`/GroupVersion#group. + resource.kind +// ^^^^^^^^ reference local resource_218 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `K8sResource.pkl`/kind. + ).filterNonNull().join("-") +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + ) + let (filePath = "\(dir)/\(baseName)") +// ^^^^^^^^ definition local filePath_230 +// ^^^ reference local dir_221 +// ^^^^^^^^ reference local baseName_222 + resource.output.renderer.extension.ifNonNull((it) -> "\(filePath).\(it)") ?? filePath +// ^^^^^^^^ reference local resource_218 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#renderer. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer#extension. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_231 +// ^^^^^^^^ reference local filePath_230 +// ^^ reference local it_231 +// ^^^^^^^^ reference local filePath_230 diff --git a/pkl-pantrysnapshot/k8s.contrib.appEnvCluster/PklProject b/pkl-pantrysnapshot/k8s.contrib.appEnvCluster/PklProject new file mode 100755 index 00000000..ae468fc8 --- /dev/null +++ b/pkl-pantrysnapshot/k8s.contrib.appEnvCluster/PklProject @@ -0,0 +1,31 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Template that captures the hierarchical pattern of Application, Environment, and Cluster. + amends "../basePklProject.pkl" + + dependencies { +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 PklProject/dependencies. + ["k8s"] { + uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 PklProject/uri. + } + } + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 PklProject/package. + version = "1.0.2" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.appEnvCluster 1.0.2 PklProject/version. + } diff --git a/pkl-pantrysnapshot/k8s.contrib.crd/PklProject b/pkl-pantrysnapshot/k8s.contrib.crd/PklProject new file mode 100755 index 00000000..489794a9 --- /dev/null +++ b/pkl-pantrysnapshot/k8s.contrib.crd/PklProject @@ -0,0 +1,38 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Utilities for [Kubernetes Custom Resources](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/). + /// + /// This package includes utilities for generating Pkl for a given CRD. + amends "../basePklProject.pkl" + + dependencies { +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 PklProject/dependencies. + ["jsonschema"] = import("../org.json_schema/PklProject") + ["jsonschema.contrib"] = import("../org.json_schema.contrib/PklProject") + ["deepToTyped"] = import("../pkl.experimental.deepToTyped/PklProject") + ["uri"] = import("../pkl.experimental.uri/PklProject") + ["syntax"] = import("../pkl.experimental.syntax/PklProject") + + ["k8s"] { uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.2.0" } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 PklProject/uri. + } + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 PklProject/package. + version = "4.0.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/k8s.contrib.crd/generate.pkl b/pkl-pantrysnapshot/k8s.contrib.crd/generate.pkl new file mode 100755 index 00000000..4fbe4fdf --- /dev/null +++ b/pkl-pantrysnapshot/k8s.contrib.crd/generate.pkl @@ -0,0 +1,285 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Generate Pkl sources from CustomResourceDefinition documents. + /// + /// Limitations: + /// - Cannot generate `not`, `allOf`, or `anyOf` combinators correctly due to limitations in Pkl's model. + /// * Union types exist, but they are logically the same as `oneOf` (only one subschema can match). + /// * Intersection types do not exist (can use this to model `allOf`). + /// - Cannot generate tuple types (this is missing in Pkl). + /// - Properties called `default` cannot be generated (currently a limitation of the json parser). + /// + /// TODO: + /// - Handle usages of `allOf`. We can do this by merging subschemas into a larger schema. + /// - Copy doc comments from a class or typealias to its usage sites if there isn't a doc comment already. + /// - Handle if schema root is not an object type (Example: ansible's schema root has `"type": "array"`). + /// - Handle if schema root should be a mapping (it has `additionalProperties` or `patternProperties` set). + /// + /// Sample CLI usage: + /// + /// ``` + /// pkl eval package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd@#/generate.pkl \ + /// -m . \ + /// -p source="https://raw.githubusercontent.com/monzo/egress-operator/master/config/crd/bases/egress.monzo.com_externalservices.yaml" + /// ``` + /// + /// Setting up replacement of Kube native types with types from the k8s standard library can be done with amending: + /// + /// ```pkl + /// amends "package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd@#/generate.pkl" + /// + /// import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/ResourceRequirements.pkl" + /// + /// source = "https://raw.githubusercontent.com/monzo/egress-operator/master/config/crd/bases/egress.monzo.com_externalservices.yaml" + /// + /// converters { + /// ["externalservices.egress.monzo.com"] { + /// [List("spec", "resources")] = ResourceRequirements + /// } + /// } + /// ``` + /// + /// To figure out which paths you need to override, try running with `-p logPaths`. + /// + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/minPklVersion. + module k8s.contrib.crd.generate +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/ + + import "pkl:yaml" + import "pkl:semver" + import "pkl:platform" + import "@deepToTyped/deepToTyped.pkl" + import "@uri/URI.pkl" + + import "internal/ModuleGenerator.pkl" + + /// The version of the Pkl Kubernetes package to import. + /// + /// This property is not used if [k8sImportPath] is set directly. + k8sVersion: String(semver.isValid(this)) = "1.0.1" +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/k8sVersion. +//documentation +//> The version of the Pkl Kubernetes package to import. +//> +//> This property is not used if [`k8sImportPath`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/k8s.contrib.crd/generate.pkl#L83,C1) is set directly. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.semver`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.semver`/isValid(). + + /// The base path to use for the Kubernetes imports. + /// + /// Examples: + /// ``` + /// // Change the version + /// k8sImportPath = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.0#" + /// + /// // Use dependency notation, assuming the dependency is called `@k8s`. + /// k8sImportPath = "@k8s" + /// ``` + k8sImportPath: String = read?("prop:k8sImportPath") ?? "package://pkg.pkl-lang.org/pkl-k8s/k8s@\(k8sVersion)#" +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/k8sImportPath. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/k8sVersion. + + baseApiGroup: String = read?("prop:baseApiGroup") ?? "k8s.io" +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/baseApiGroup. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Where to find the CRDs; can be a URI (`https:`, `file:` etc), an absolute file path, or a relative file path + source: String = read("prop:source") +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/source. +//documentation +//> Where to find the CRDs; can be a URI (`https:`, `file:` etc), an absolute file path, or a relative file path +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + local sourceUri = +// ^^^^^^^^^ definition local sourceUri_90 + if (source.startsWith(Regex(#"\w+:"#))) source // absolute URI +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/source. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/source. + else if (source.startsWith("/")) "file://\(source)" // absolute file path +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/source. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/source. + else // relative file path + let (pwd = read("env:PWD")) +// ^^^ definition local pwd_94 + let (path = +// ^^^^ definition local path_95 + if (platform.current.operatingSystem.name == "Windows") "/\(pwd)/\(source)".replaceAll("\\", "/") +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/current. +// ^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/Platform#operatingSystem. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/OperatingSystem#name. +// ^^^ reference local pwd_94 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/source. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + else "\(pwd)/\(source)" +// ^^^ reference local pwd_94 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/source. + ) + "file://\(URI.encode(path))" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^ reference local path_95 + + /// The CRD's source contents, as computed from [source]. + sourceContents: String|Resource = read(URI.encode(sourceUri)) +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/sourceContents. +//documentation +//> The CRD's source contents, as computed from [`source`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/k8s.contrib.crd/generate.pkl#L88,C1). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^^^^^^ reference local sourceUri_90 + + /// Whether to log out every path we find in each CRD to aid in setting converters. + /// + /// Default: `false`. + logPaths: Boolean? = read?("prop:logPaths")?.toBoolean() +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/logPaths. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toBoolean(). + + local crds: Listing = +// ^^^^ definition local crds_109 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/CRD# + let (parser = new yaml.Parser { useMapping = true }) +// ^^^^^^ definition local parser_110 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Parser# +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/useMapping. + new { + for (crd in parser.parseAll(sourceContents)) { +// ^^^ definition local crd_112 +// ^^^^^^ reference local parser_110 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Parser#parseAll(). +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/sourceContents. + when (crd is Mapping && crd.getOrNull("kind") == "CustomResourceDefinition") { +// ^^^ reference local crd_112 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference local crd_112 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + deepToTyped.apply(ModuleGenerator.CRD, crd) as ModuleGenerator.CRD +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/CRD# +// ^^^ reference local crd_112 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/CRD# + } + } + } + + /// Type conversions when generating property types. + /// + /// This is a two-dimensional mapping, where top-level entries designate CRD names (for example, + /// "restateclusters.restate.dev"). + /// + /// The inner mapping specifies how individual paths within a CRD should be mapped to a custom type. + /// + /// Example: + /// ``` + /// converters { + /// ["restateclusters.restate.dev"] { + /// [List("spec", "compute", "env", "env")] = EnvVar + /// } + /// } + /// ``` + converters: Mapping, Module|Class|TypeAlias>>? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/converters. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# + + fixed modules: Listing = new { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/modules. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ + for (_crd in crds) { +// ^^^^ definition local _crd_137 +// ^^^^ reference local crds_109 + for (_version in _crd.spec.versions) { +// ^^^^^^^^ definition local _version_138 +// ^^^^ reference local _crd_137 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/spec. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/CustomResourceDefinitionSpec#versions. + new ModuleGenerator { +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ + k8sImportPath = module.k8sImportPath +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/k8sImportPath. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/k8sImportPath. + crd = _crd +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/crd. +// ^^^^ reference local _crd_137 + version = _version +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/version. +// ^^^^^^^^ reference local _version_138 + baseUri = URI.parse(sourceUri)!! +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/baseUri. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^^^ reference local sourceUri_90 + converters = module.converters?.getOrNull(crd.metadata.name) ?? new Mapping {} +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/converters. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/converters. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/crd. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/metadata. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl`/name. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + logPaths = module.logPaths ?? false +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/logPaths. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/logPaths. + } + } + } + } + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/output. + text = throw("The JSON Schema generator only works with multiple-file output. Try running again with the -m option.") +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/text. + files { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/files. + for (mod in modules) { +// ^^^ definition local mod_154 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/modules. + ["\(mod.moduleName.replaceFirst(Regex(#"^\#(baseApiGroup)\."#), "").split(".").join("/")).pkl"] = mod.moduleNode.output +// ^^^ reference local mod_154 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/baseApiGroup. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). +// ^^^ reference local mod_154 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. + } + } + } + diff --git a/pkl-pantrysnapshot/k8s.contrib.crd/internal/ModuleGenerator.pkl b/pkl-pantrysnapshot/k8s.contrib.crd/internal/ModuleGenerator.pkl new file mode 100755 index 00000000..9c418970 --- /dev/null +++ b/pkl-pantrysnapshot/k8s.contrib.crd/internal/ModuleGenerator.pkl @@ -0,0 +1,1169 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Support for generating classes. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/minPklVersion. + @Unlisted +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Unlisted# + module k8s.contrib.crd.internal.ModuleGenerator +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ + + import "pkl:reflect" + import "@jsonschema.contrib/internal/Type.pkl" + import "@jsonschema.contrib/internal/TypesGenerator.pkl" + import "@jsonschema.contrib/internal/utils.pkl" + import "@jsonschema.contrib/internal/singularize.pkl" + import "@jsonschema/JsonSchema.pkl" + import "@jsonschema/Parser.pkl" + import "@k8s/apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl" + import "@k8s/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl" as BetaCRD + import "@syntax/ClassNode.pkl" + import "@syntax/ClassOrModuleNode.pkl" + import "@syntax/DocCommentNode.pkl" + import "@syntax/ModuleNode.pkl" + import "@syntax/TypeNode.pkl" + import "@uri/URI.pkl" + + local pcfRenderer = new PcfRenderer { useCustomStringDelimiters = true } +// ^^^^^^^^^^^ definition local pcfRenderer_37 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer# +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/useCustomStringDelimiters. + local jsonRenderer = new JsonRenderer {} +// ^^^^^^^^^^^^ definition local jsonRenderer_38 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer# + + // noinspection Deprecated + typealias CRD = CustomResourceDefinition|BetaCRD +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/CRD# +// ^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl`/ + + /// The CRD + crd: CRD +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/crd. +//documentation +//> The CRD +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/CRD# + + /// The CRD version to generate + version: CustomResourceDefinition.CustomResourceDefinitionVersion|BetaCRD.CustomResourceDefinitionVersion +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/version. +//documentation +//> The CRD version to generate +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/CustomResourceDefinitionVersion# +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl`/CustomResourceDefinitionVersion# + + logPaths: Boolean = false +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/logPaths. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + k8sImportPath: String +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/k8sImportPath. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + // noinspection Deprecated + local schema: CustomResourceDefinition.CustomResourceValidation|BetaCRD.CustomResourceValidation = +// ^^^^^^ definition local schema_54 +// ^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/CustomResourceValidation# +// ^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl`/CustomResourceValidation# + (if (crd is BetaCRD) version.schema ?? crd.spec.validation else version.schema)!! +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/crd. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/version. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl`/CustomResourceDefinitionVersion#schema. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/crd. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl`/spec. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl`/CustomResourceDefinitionSpec#validation. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/version. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl`/CustomResourceDefinitionVersion#schema. + + /// The Schema + rootSchema: JsonSchema(validCRDSchema(this)) = Parser.parse(new JsonRenderer {}.renderDocument(schema.openAPIV3Schema)) as JsonSchema +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/rootSchema. +//documentation +//> The Schema +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/parse(). +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer# +// ^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer#renderDocument(). +// ^^^^^^ reference local schema_54 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl`/CustomResourceValidation#openAPIV3Schema. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + + local ignoreProperties = Set("apiVersion", "kind", "metadata") +// ^^^^^^^^^^^^^^^^ definition local ignoreProperties_60 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). + local filteredRootSchema = (rootSchema) { +// ^^^^^^^^^^^^^^^^^^ definition local filteredRootSchema_61 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/rootSchema. + when (rootSchema.properties != null) { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + properties = new { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/properties. + for (k, v in rootSchema.properties!!) { +// ^ definition local k_64 +// ^ definition local v_64 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + when (!ignoreProperties.contains(k)) { +// ^^^^^^^^^^^^^^^^ reference local ignoreProperties_60 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). +// ^ reference local k_64 + [k] = v +// ^ reference local k_64 +// ^ reference local v_64 + } + } + } + } + } + + // https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation + local function validCRDSchema(schema: (JsonSchema.Schema|Listing)?) = +// ^^^^^^^^^^^^^^ definition local validCRDSchema_74 +// ^^^^^^ definition local schema_74 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + if (schema == null) +// ^^^^^^ reference local schema_74 + true + else if (schema is JsonSchema) +// ^^^^^^ reference local schema_74 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + validCRDJsonSchema(schema) +// ^^^^^^^^^^^^^^^^^^ reference local validCRDJsonSchema_84 +// ^^^^^^ reference local schema_74 + else if (schema is Listing) +// ^^^^^^ reference local schema_74 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + schema.toList().every((s) -> validCRDSchema(s)) +// ^^^^^^ reference local schema_74 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^ definition local s_80 +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^ reference local s_80 + else + true + + local function validCRDJsonSchema(schema: JsonSchema) = +// ^^^^^^^^^^^^^^^^^^ definition local validCRDJsonSchema_84 +// ^^^^^^ definition local schema_84 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + schema.definitions == null +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/definitions. + && schema.$defs == null +// ^^^^^^ reference local schema_84 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$defs. + && schema.deprecated == null +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/deprecated. + && schema.$id == null +// ^^^^^^ reference local schema_84 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$id. + && schema.patternProperties == null +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/patternProperties. + && schema.readOnly == null +// ^^^^^^ reference local schema_84 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/readOnly. + && schema.writeOnly == null +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/writeOnly. + && schema.$ref == null +// ^^^^^^ reference local schema_84 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$ref. + && schema.uniqueItems != true +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/uniqueItems. + && (schema.properties?.toMap()?.values?.every((s) -> validCRDSchema(s)) ?? true) +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^ definition local s_94 +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^ reference local s_94 + && schema.additionalProperties != false +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. + && !(schema.additionalProperties != null && schema.properties != null) +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + && validCRDSchema(schema.additionalProperties) +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. + && validCRDSchema(schema.propertyNames) +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/propertyNames. + && validCRDSchema(schema.items) +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^^^^^^ reference local schema_84 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. + && validCRDSchema(schema.additionalItems) +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^^^^^^ reference local schema_84 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalItems. + && validCRDSchema(schema.contains) +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^^^^^^ reference local schema_84 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/contains. + && validCRDSchema(schema.oneOf) +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^^^^^^ reference local schema_84 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/oneOf. + && validCRDSchema(schema.anyOf) +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^^^^^^ reference local schema_84 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/anyOf. + && validCRDSchema(schema.allOf) +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^^^^^^ reference local schema_84 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/allOf. + && validCRDSchema(schema.not) +// ^^^^^^^^^^^^^^ reference local validCRDSchema_74 +// ^^^^^^ reference local schema_84 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/not. + + + + converters: Mapping, Module|Class|TypeAlias> +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/converters. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# + + /// The URI representing the root schema, used for the doc comment. + baseUri: URI +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/baseUri. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + + /// The name of this module + moduleName: String = crd.spec.group.split(".").reverse() +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleName. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/crd. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/spec. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/CustomResourceDefinitionSpec#group. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#reverse(). + .add(version.name) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/version. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl`/CustomResourceDefinitionVersion#name. + .add(crd.spec.names.kind) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/crd. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/spec. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/CustomResourceDefinitionSpec#names. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/CustomResourceDefinitionNames#kind. + .join(".") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + local typesGenerator: TypesGenerator = new { baseUri = new {}; enclosingModuleName = moduleName } +// ^^^^^^^^^^^^^^ definition local typesGenerator_120 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/baseUri. +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/enclosingModuleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleName. + + /// The types described in this JSON Schema document, included those replaced via converters + moduleTypes: Type.TypeNames = convertedSchemas.map((schema, importAndType) -> Pair(schema, importAndType.type)) + classSchemas +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleTypes. +//documentation +//> The types described in this JSON Schema document, included those replaced via converters +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^^^^^^^^^^^^^^ reference local convertedSchemas_404 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#map(). +// ^^^^^^ definition local schema_123 +// ^^^^^^^^^^^^^ definition local importAndType_123 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_123 +// ^^^^^^^^^^^^^ reference local importAndType_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ImportAndType#type. +// ^^^^^^^^^^^^ reference local classSchemas_350 + + /// Generate a Pkl [ModuleNode] from a given schema. + moduleNode: ModuleNode = +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleNode. +//documentation +//> Generate a Pkl [`ModuleNode`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.syntax/ModuleNode.pkl#L18,C1) from a given schema. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ + let (allTypeNames = moduleTypes) +// ^^^^^^^^^^^^ definition local allTypeNames_127 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleTypes. + new { + imports { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/imports. + new { + value = "\(k8sImportPath)/apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/k8sImportPath. + } + for (_import in convertedSchemas.values.map((it) -> it._import).toSet()) { +// ^^^^^^^ definition local _import_133 +// ^^^^^^^^^^^^^^^^ reference local convertedSchemas_404 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local it_133 +// ^^ reference local it_133 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ImportAndType#_import. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toSet(). + new { + value = _import +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. +// ^^^^^^^ reference local _import_133 + } + } + } + classes { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/classes. + for (schema, type in classSchemas) { +// ^^^^^^ definition local schema_140 +// ^^^^ definition local type_140 +// ^^^^^^^^^^^^ reference local classSchemas_350 + generatePklClass(schema, type, allTypeNames) +// ^^^^^^^^^^^^^^^^ reference local generatePklClass_265 +// ^^^^^^ reference local schema_140 +// ^^^^ reference local type_140 +// ^^^^^^^^^^^^ reference local allTypeNames_127 + } + } + declaration { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/declaration. + docComment = getDocComment(filteredRootSchema, "module") +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/docComment. +// ^^^^^^^^^^^^^ reference local getDocComment_208 +// ^^^^^^^^^^^^^^^^^^ reference local filteredRootSchema_61 + moduleHeader { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleHeader. + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/parts. + for (part in moduleName.split(".")) { +// ^^^^ definition local part_149 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleName. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). + new { value = part } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. +// ^^^^ reference local part_149 + } + } + } + moduleExtendsOrAmendsClause { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleExtendsOrAmendsClause. + type = "extends" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/type. + extendedModule = "\(k8sImportPath)/K8sResource.pkl" +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/extendedModule. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/k8sImportPath. + } + } + } + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/properties. + new { + modifiers { "fixed" } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/modifiers. + name { value = "apiVersion" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/typeAnnotation. + type = new TypeNode.StringLiteralTypeNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/type. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# + value = "\(crd.spec.group)/\(version.name)" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/crd. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/spec. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/CustomResourceDefinitionSpec#group. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/version. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/CustomResourceDefinition.pkl`/CustomResourceDefinitionVersion#name. + } + } + } + new { + modifiers { "fixed" } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/modifiers. + name { value = "kind" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/typeAnnotation. + type = new TypeNode.StringLiteralTypeNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/type. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# + value = crd.spec.names.kind +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/crd. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/spec. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/CustomResourceDefinitionSpec#names. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `apiextensions-apiserver/pkg/apis/apiextensions/v1/CustomResourceDefinition.pkl`/CustomResourceDefinitionNames#kind. + } + } + } + new { + name { value = "metadata" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. + docComment { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/docComment. + value = """ +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. + Standard object's metadata. + + More info: . + """ + } + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/typeAnnotation. + type = new TypeNode.NullableTypeNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/type. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode# + typeNode = new TypeNode.DeclaredTypeNode { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/typeNode. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/parts. + new { + value = "ObjectMeta" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. + } + } + } + } + } + } + } + when (isClassLike(filteredRootSchema)) { +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/isClassLike(). +// ^^^^^^^^^^^^^^^^^^ reference local filteredRootSchema_61 + ...generateClassBody(filteredRootSchema, allTypeNames) +// ^^^^^^^^^^^^^^^^^ reference local generateClassBody_238 +// ^^^^^^^^^^^^^^^^^^ reference local filteredRootSchema_61 +// ^^^^^^^^^^^^ reference local allTypeNames_127 + } + } + } + + /// Determine the doc comments of a schema. + /// + /// This combines a schema's title, description and "default" descriptions into one doc comment. + /// Wraps the comments at 100 columns. + local function getDocComment(schema: JsonSchema|Boolean, type: "class"|"module"|Null): DocCommentNode? = +// ^^^^^^^^^^^^^ definition local getDocComment_208 +// documentation +// > Determine the doc comments of a schema. +// > +// > This combines a schema's title, description and "default" descriptions into one doc comment. +// > Wraps the comments at 100 columns. +// ^^^^^^ definition local schema_212 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^ definition local type_212 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/ + if (schema is Boolean) +// ^^^^^^ reference local schema_212 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + null + else + let (docCommentText: String = +// ^^^^^^^^^^^^^^ definition local docCommentText_216 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + schema.description +// ^^^^^^ reference local schema_212 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/description. + when (type is "module") { "This module was generated from the CustomResourceDefinition at <\(baseUri)>." } +// ^^^^ reference local type_212 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/baseUri. + when (type is "class"|"module") { getWarnings(schema, type) } +// ^^^^ reference local type_212 +// ^^^^^^^^^^^ reference local getWarnings_231 +// ^^^^^^ reference local schema_212 +// ^^^^ reference local type_212 + when (schema.default != null) { "Default if undefined: `\(pcfRenderer.renderValue(schema.default))`" } +// ^^^^^^ reference local schema_212 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/default. +// ^^^^^^^^^^^ reference local pcfRenderer_37 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer#renderValue(). +// ^^^^^^ reference local schema_212 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/default. + }.toList().filterNonNull().join("\n\n") +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + ) + if (docCommentText.isEmpty) null +// ^^^^^^^^^^^^^^ reference local docCommentText_216 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. + else + new DocCommentNode { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/ + value = docCommentText +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. +// ^^^^^^^^^^^^^^ reference local docCommentText_216 + autoWrap = true +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/autoWrap. + } + + local function getWarnings(schema: JsonSchema, type: "class"|"module"): String? = +// ^^^^^^^^^^^ definition local getWarnings_231 +// ^^^^^^ definition local schema_231 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition local type_231 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (type == "class") null +// ^^^^ reference local type_231 + else if (schema.type != null && schema.type != "object") +// ^^^^^^ reference local schema_231 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^ reference local schema_231 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. + "WARN: The root schema's type is `\(jsonRenderer.renderValue(schema.type))`, and cannot be correctly mapped to a Pkl module." +// ^^^^^^^^^^^^ reference local jsonRenderer_38 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer#renderValue(). +// ^^^^^^ reference local schema_231 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. + else + null + + local function generateClassBody( +// ^^^^^^^^^^^^^^^^^ definition local generateClassBody_238 + schema: JsonSchema(this.properties != null), +// ^^^^^^ definition local schema_239 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + typeNames: Type.TypeNames +// ^^^^^^^^^ definition local typeNames_240 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# + ): Listing = +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode# + new { + for (propName, propSchema in schema.properties!!) { +// ^^^^^^^^ definition local propName_243 +// ^^^^^^^^^^ definition local propSchema_243 +// ^^^^^^ reference local schema_239 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + new { + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/name. + value = propName +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. +// ^^^^^^^^ reference local propName_243 + } + when (propSchema is JsonSchema && propSchema.deprecated == true) { +// ^^^^^^^^^^ reference local propSchema_243 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^ reference local propSchema_243 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/deprecated. + annotations { utils.DEPRECATED } +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/annotations. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/DEPRECATED. + } + docComment = getDocComment(propSchema, null) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/docComment. +// ^^^^^^^^^^^^^ reference local getDocComment_208 +// ^^^^^^^^^^ reference local propSchema_243 + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/typeAnnotation. + // If this property doesn't appear in the `required` array, mark it as nullable. + // We can't do this within [TypesGenerator] because it doesn't have enough information available. + type = let (underlyingType = typesGenerator.generateTypeNode(propSchema, typeNames)) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/type. +// ^^^^^^^^^^^^^^ definition local underlyingType_255 +// ^^^^^^^^^^^^^^ reference local typesGenerator_120 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference local propSchema_243 +// ^^^^^^^^^ reference local typeNames_240 + if (schema.required?.toSet()?.contains(propName) ?? false) underlyingType +// ^^^^^^ reference local schema_239 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/required. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toSet(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). +// ^^^^^^^^ reference local propName_243 +// ^^^^^^^^^^^^^^ reference local underlyingType_255 + // If the type is already nullable, no need to make it *more* nullable. + else if (underlyingType is TypeNode.NullableTypeNode) underlyingType +// ^^^^^^^^^^^^^^ reference local underlyingType_255 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode# +// ^^^^^^^^^^^^^^ reference local underlyingType_255 + else new TypeNode.NullableTypeNode { typeNode = underlyingType } +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/typeNode. +// ^^^^^^^^^^^^^^ reference local underlyingType_255 + } + } + } + } + + /// Generates a [ClassNode] from a [CRDJsonSchema]. + local function generatePklClass(schema: JsonSchema, className: Type, typeNames: Type.TypeNames): ClassNode = +// ^^^^^^^^^^^^^^^^ definition local generatePklClass_265 +// documentation +// > Generates a [`ClassNode`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.syntax/ClassNode.pkl#L16,C1) from a `CRDJsonSchema`. +// ^^^^^^ definition local schema_266 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ definition local className_266 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ +// ^^^^^^^^^ definition local typeNames_266 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ + new { + docComment = getDocComment(schema, "class") +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/docComment. +// ^^^^^^^^^^^^^ reference local getDocComment_208 +// ^^^^^^ reference local schema_266 + classHeader { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/classHeader. + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/name. + value = className.name +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/value. +// ^^^^^^^^^ reference local className_266 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/name. + } + } + properties = generateClassBody(schema, typeNames) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/properties. +// ^^^^^^^^^^^^^^^^^ reference local generateClassBody_238 +// ^^^^^^ reference local schema_266 +// ^^^^^^^^^ reference local typeNames_266 + } + + function isClassLike(schema: JsonSchema.Schema): Boolean = +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/isClassLike(). +// ^^^^^^ definition local schema_277 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + !(schema is Boolean) && schema.properties != null +// ^^^^^^ reference local schema_277 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference local schema_277 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + + // only need to include stdlib names that would be used by the code generator + const local builtInNames = Set( +// ^^^^^^^^^^^^ definition local builtInNames_281 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). + "Mapping", + "Listing", + "Dynamic", + "String", + "Boolean", + "Int", + "Int16", + "Int32", + "UInt", + "UInt8", + "UInt16", + "UInt32", + "Float", + "Null", + "Number", + "Deprecated" + ) + + local function normalizeTypeName(name: String) = +// ^^^^^^^^^^^^^^^^^ definition local normalizeTypeName_300 +// ^^^^ definition local name_300 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (capitalized = utils.pascalCase(name)) +// ^^^^^^^^^^^ definition local capitalized_301 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/pascalCase(). +// ^^^^ reference local name_300 + if (builtInNames.contains(capitalized)) "\(capitalized)1" +// ^^^^^^^^^^^^ reference local builtInNames_281 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). +// ^^^^^^^^^^^ reference local capitalized_301 +// ^^^^^^^^^^^ reference local capitalized_301 + else capitalized +// ^^^^^^^^^^^ reference local capitalized_301 + + /// Determines the name of a type. + /// + /// Try to use the parent property's name as part of the class name in case of conflict. + /// If already at the root, add a number at the end. + local function determineTypeName( +// ^^^^^^^^^^^^^^^^^ definition local determineTypeName_305 +// documentation +// > Determines the name of a type. +// > +// > Try to use the parent property's name as part of the class name in case of conflict. +// > If already at the root, add a number at the end. + path: List, +// ^^^^ definition local path_310 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + candidateName: String, +// ^^^^^^^^^^^^^ definition local candidateName_311 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + existingTypeNames: Set, +// ^^^^^^^^^^^^^^^^^ definition local existingTypeNames_312 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ + index: Int +// ^^^^^ definition local index_313 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + ): Type = +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ + let (candidate = normalizeTypeName(candidateName)) +// ^^^^^^^^^ definition local candidate_315 +// ^^^^^^^^^^^^^^^^^ reference local normalizeTypeName_300 +// ^^^^^^^^^^^^^ reference local candidateName_311 + if (existingTypeNames.findOrNull((it) -> it.name == candidate) != null) +// ^^^^^^^^^^^^^^^^^ reference local existingTypeNames_312 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#findOrNull(). +// ^^ definition local it_316 +// ^^ reference local it_316 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/name. +// ^^^^^^^^^ reference local candidate_315 + if (path.isEmpty) +// ^^^^ reference local path_310 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + determineTypeName( +// ^^^^^^^^^^^^^^^^^ reference local determineTypeName_305 + path, +// ^^^^ reference local path_310 + candidateName + index.toString(), +// ^^^^^^^^^^^^^ reference local candidateName_311 +// ^^^^^ reference local index_313 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + existingTypeNames, +// ^^^^^^^^^^^^^^^^^ reference local existingTypeNames_312 + index + 1 +// ^^^^^ reference local index_313 + ) + else + let (newPath = dropLast(path)) +// ^^^^^^^ definition local newPath_325 +// ^^^^^^^^ reference local dropLast_344 +// ^^^^ reference local path_310 + determineTypeName( +// ^^^^^^^^^^^^^^^^^ reference local determineTypeName_305 + newPath, +// ^^^^^^^ reference local newPath_325 + getCandidateName(newPath) + candidate, +// ^^^^^^^^^^^^^^^^ reference local getCandidateName_336 +// ^^^^^^^ reference local newPath_325 +// ^^^^^^^^^ reference local candidate_315 + existingTypeNames, +// ^^^^^^^^^^^^^^^^^ reference local existingTypeNames_312 + index +// ^^^^^ reference local index_313 + ) + else + new { name = candidate; moduleName = module.moduleName } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/name. +// ^^^^^^^^^ reference local candidate_315 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleName. + + // noinspection TypeMismatch + local function getCandidateName(path: List) = +// ^^^^^^^^^^^^^^^^ definition local getCandidateName_336 +// ^^^^ definition local path_336 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (path.isEmpty) +// ^^^^ reference local path_336 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + "Item" + else if (path.last == "[]") +// ^^^^ reference local path_336 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + path.dropLast(1).lastOrNull?.ifNonNull((it) -> utils.pascalCase(singularize.singularize(it))) ?? "Item" +// ^^^^ reference local path_336 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#dropLast(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#lastOrNull. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_340 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/pascalCase(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/singularize.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/singularize.pkl`/singularize(). +// ^^ reference local it_340 + else + utils.pascalCase(path.last) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/pascalCase(). +// ^^^^ reference local path_336 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + + local function dropLast(path: List) = +// ^^^^^^^^ definition local dropLast_344 +// ^^^^ definition local path_344 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (path.last == "[]") +// ^^^^ reference local path_344 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + path.dropLast(2) +// ^^^^ reference local path_344 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#dropLast(). + else + path.dropLast(1) +// ^^^^ reference local path_344 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#dropLast(). + + /// The schemas that should be rendered as classes. + /// + /// Classes get rendered for any subschema that has [JsonSchema.properties] defined, and does not show up in converters + local classSchemas: Type.TypeNames = +// ^^^^^^^^^^^^ definition local classSchemas_350 +// documentation +// > The schemas that should be rendered as classes. +// > +// > Classes get rendered for any subschema that has [`JsonSchema.properties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L325,C1) defined, and does not show up in converters +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# + utils._findMatchingSubSchemas(filteredRootSchema, List(), (elem) -> elem != filteredRootSchema && isClassLike(elem)) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). +// ^^^^^^^^^^^^^^^^^^ reference local filteredRootSchema_61 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^ definition local elem_354 +// ^^^^ reference local elem_354 +// ^^^^^^^^^^^^^^^^^^ reference local filteredRootSchema_61 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/isClassLike(). +// ^^^^ reference local elem_354 + // path or prefix are not explicitly in converters + .filter((path, _) -> !pathPrefixes(path).any((prefix) -> converters.containsKey(prefix))) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^ definition local path_356 +// ^^^^^^^^^^^^ reference local pathPrefixes_366 +// ^^^^ reference local path_356 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#any(). +// ^^^^^^ definition local prefix_356 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/converters. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). +// ^^^^^^ reference local prefix_356 + .entries +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. + .fold(Map(), (accumulator: Type.TypeNames, pair) -> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^^^^^^ definition local accumulator_358 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^^ definition local pair_358 + let (path = pair.first) +// ^^^^ definition local path_359 +// ^^^^ reference local pair_358 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + let (schema = pair.second) +// ^^^^^^ definition local schema_360 +// ^^^^ reference local pair_358 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + let (typeName = determineTypeName(path, getCandidateName(path), accumulator.values.toSet(), 0)) +// ^^^^^^^^ definition local typeName_361 +// ^^^^^^^^^^^^^^^^^ reference local determineTypeName_305 +// ^^^^ reference local path_359 +// ^^^^^^^^^^^^^^^^ reference local getCandidateName_336 +// ^^^^ reference local path_359 +// ^^^^^^^^^^^ reference local accumulator_358 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toSet(). + accumulator.put(schema, typeName) +// ^^^^^^^^^^^ reference local accumulator_358 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#put(). +// ^^^^^^ reference local schema_360 +// ^^^^^^^^ reference local typeName_361 + ) + + // Return all possible path prefixes of this path, starting with its first entry and ending with the full path + local function pathPrefixes(path: List): List> = new Listing { +// ^^^^^^^^^^^^ definition local pathPrefixes_366 +// ^^^^ definition local path_366 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + for (i, _ in path) { +// ^ definition local i_367 +// ^^^^ reference local path_366 + path.take(i + 1) +// ^^^^ reference local path_366 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#take(). +// ^ reference local i_367 + } + }.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + + /// mapSchema deeply transforms a CRD schema. CRD schemas are significantly simplified, as many fields must not be set. + /// Nested types are *always* represented in properties, items or additionalProperties, even if they are also set in oneOf etc + function mapSchema( +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/mapSchema(). +// documentation +// > mapSchema deeply transforms a CRD schema. CRD schemas are significantly simplified, as many fields must not be set. +// > Nested types are *always* represented in properties, items or additionalProperties, even if they are also set in oneOf etc + schema: JsonSchema.Schema, +// ^^^^^^ definition local schema_375 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + path: Listing, +// ^^^^ definition local path_376 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + f: (JsonSchema.Schema) -> JsonSchema.Schema +// ^ definition local f_377 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + ): JsonSchema.Schema = +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + let (applied = f.apply(schema)) +// ^^^^^^^ definition local applied_379 +// ^ reference local f_377 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^^ reference local schema_375 + (applied) { +// ^^^^^^^ reference local applied_379 + when (applied.properties != null) { +// ^^^^^^^ reference local applied_379 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + properties = new { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/properties. + for (name, property in applied.properties!!) { +// ^^^^ definition local name_383 +// ^^^^^^^^ definition local property_383 +// ^^^^^^^ reference local applied_379 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + [name] = mapSchema(property, (path) { name }, f) +// ^^^^ reference local name_383 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/mapSchema(). +// ^^^^^^^^ reference local property_383 +// ^^^^ reference local path_376 +// ^^^^ reference local name_383 +// ^ reference local f_377 + } + } + } + when (applied.additionalProperties != null) { +// ^^^^^^^ reference local applied_379 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. + additionalProperties = mapSchema(applied.additionalProperties!!, (path) { "additionalProperties" }, f) +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/additionalProperties. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/mapSchema(). +// ^^^^^^^ reference local applied_379 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. +// ^^^^ reference local path_376 +// ^ reference local f_377 + } + when (applied.items != null) { +// ^^^^^^^ reference local applied_379 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. + when (applied.items is Listing) { +// ^^^^^^^ reference local applied_379 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + items = new { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/items. + for (i, item in applied.items as Listing) { +// ^ definition local i_394 +// ^^^^ definition local item_394 +// ^^^^^^^ reference local applied_379 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + [i] = mapSchema(item, (path) { i.toString() }, f) +// ^ reference local i_394 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/mapSchema(). +// ^^^^ reference local item_394 +// ^^^^ reference local path_376 +// ^ reference local i_394 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). +// ^ reference local f_377 + } + } + } else { + items = mapSchema(applied.items as JsonSchema.Schema, (path) { "items" }, f) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/items. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/mapSchema(). +// ^^^^^^^ reference local applied_379 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^ reference local path_376 +// ^ reference local f_377 + } + } + } + + local convertedSchemas: Map = +// ^^^^^^^^^^^^^^^^ definition local convertedSchemas_404 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ImportAndType# + utils.findMatchingSubschemas(filteredRootSchema, (elem) -> elem != filteredRootSchema) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/findMatchingSubschemas(). +// ^^^^^^^^^^^^^^^^^^ reference local filteredRootSchema_61 +// ^^^^ definition local elem_405 +// ^^^^ reference local elem_405 +// ^^^^^^^^^^^^^^^^^^ reference local filteredRootSchema_61 + .filter((path, _) -> converters.containsKey(if (logPaths) trace(path) else path)) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^ definition local path_406 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/converters. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/logPaths. +// ^^^^ reference local path_406 +// ^^^^ reference local path_406 + .entries +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. + .fold(Map(), (accumulator: Map, pair) -> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^^^^^^ definition local accumulator_408 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ImportAndType# +// ^^^^ definition local pair_408 + let (path = pair.first) +// ^^^^ definition local path_409 +// ^^^^ reference local pair_408 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + let (schema = pair.second) +// ^^^^^^ definition local schema_410 +// ^^^^ reference local pair_408 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + let (converted = converters[path]) +// ^^^^^^^^^ definition local converted_411 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/converters. +// ^^^^ reference local path_409 + let (reflected = +// ^^^^^^^^^ definition local reflected_412 + if (converted is Module) +// ^^^^^^^^^ reference local converted_411 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module# + reflect.Module(converted) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module(). +// ^^^^^^^^^ reference local converted_411 + else if (converted is TypeAlias) +// ^^^^^^^^^ reference local converted_411 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# + reflect.TypeAlias(converted) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias(). +// ^^^^^^^^^ reference local converted_411 + else + reflect.Class(converted) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^^^^^^^^^ reference local converted_411 + ) + accumulator.put(schema, new ImportAndType { +// ^^^^^^^^^^^ reference local accumulator_408 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#put(). +// ^^^^^^ reference local schema_410 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ImportAndType# + type { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/type. + moduleName = if (reflected is reflect.Module) module.moduleName else reflected.enclosingDeclaration.name +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^ reference local reflected_412 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^ reference local reflected_412 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#enclosingDeclaration. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#name. + name = reflected.name.split(".").last +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/name. +// ^^^^^^^^^ reference local reflected_412 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#name. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + } + local uri = +// ^^^ definition local uri_425 + if (reflected is reflect.Module) +// ^^^^^^^^^ reference local reflected_412 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module# + reflected.uri +// ^^^^^^^^^ reference local reflected_412 +// ^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#uri. + else + reflected.enclosingDeclaration.uri +// ^^^^^^^^^ reference local reflected_412 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#enclosingDeclaration. +// ^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#uri. + _import = determineImportPath(uri) +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/_import. +// ^^^^^^^^^^^^^^^^^^^ reference local determineImportPath_434 +// ^^^ reference local uri_425 + }) + ) + + /// If any conversions are from the core k8s library, replace the import path with [k8sImportPath] + local function determineImportPath(uri: String): String = +// ^^^^^^^^^^^^^^^^^^^ definition local determineImportPath_434 +// documentation +// > If any conversions are from the core k8s library, replace the import path with [`k8sImportPath`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/k8s.contrib.crd/internal/ModuleGenerator.pkl#L51,C1) +// ^^^ definition local uri_435 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if ( + uri.startsWith("package://pkg.pkl-lang.org/pkl-k8s/k8s") +// ^^^ reference local uri_435 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + || uri.startsWith("projectpackage://pkg.pkl-lang.org/pkl-k8s/k8s") +// ^^^ reference local uri_435 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + ) + k8sImportPath + uri.dropWhile((it) -> it != "#").drop(1) +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/k8sImportPath. +// ^^^ reference local uri_435 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#dropWhile(). +// ^^ definition local it_440 +// ^^ reference local it_440 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). + else uri +// ^^^ reference local uri_435 + + class ImportAndType { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ImportAndType# + _import: String +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ImportAndType#_import. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + type: Type +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `internal/ModuleGenerator.pkl`/ImportAndType#type. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ + } + diff --git a/pkl-pantrysnapshot/k8s.contrib.crd/tests/ModuleGenerator.pkl b/pkl-pantrysnapshot/k8s.contrib.crd/tests/ModuleGenerator.pkl new file mode 100755 index 00000000..553dd381 --- /dev/null +++ b/pkl-pantrysnapshot/k8s.contrib.crd/tests/ModuleGenerator.pkl @@ -0,0 +1,158 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module k8s.contrib.crd.tests.ModuleGenerator +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/ + + amends "pkl:test" + + import "@k8s/api/core/v1/ResourceRequirements.pkl" + import "@k8s/api/core/v1/EnvVar.pkl" + import "@k8s/api/networking/v1/NetworkPolicy.pkl" + + import "../generate.pkl" + + local generator = (generate) { +// ^^^^^^^^^ definition local generator_26 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/ + sourceContents = read("fixtures/crds.yaml") +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/sourceContents. + source = "dummy://test_uri" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/source. + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/converters. + ["restateclusters.restate.dev"] { + [List("spec", "compute", "env", "[]")] = EnvVar +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `api/core/v1/EnvVar.pkl`/ + [List("spec", "compute", "resources")] = ResourceRequirements +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `api/core/v1/ResourceRequirements.pkl`/ + [List("spec", "security", "networkPeers", "ingress", "[]")] = NetworkPolicy.NetworkPolicyPeer +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `api/networking/v1/NetworkPolicy.pkl`/ +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `api/networking/v1/NetworkPolicy.pkl`/NetworkPolicyPeer# + [List("spec", "security", "networkPeers", "admin", "[]")] = NetworkPolicy.NetworkPolicyPeer +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `api/networking/v1/NetworkPolicy.pkl`/ +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `api/networking/v1/NetworkPolicy.pkl`/NetworkPolicyPeer# + [List("spec", "security", "networkPeers", "metrics", "[]")] = NetworkPolicy.NetworkPolicyPeer +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `api/networking/v1/NetworkPolicy.pkl`/ +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.2.0 `api/networking/v1/NetworkPolicy.pkl`/NetworkPolicyPeer# + } + } + } + + local generator2 = (generator) { +// ^^^^^^^^^^ definition local generator2_40 +// ^^^^^^^^^ reference local generator_26 + k8sImportPath = "@k8s" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/k8sImportPath. + } + + local generator3 = (generator) { +// ^^^^^^^^^^ definition local generator3_44 +// ^^^^^^^^^ reference local generator_26 + k8sImportPath = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/k8sImportPath. + } + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/examples. + for (filename, value in generator.output.files!!) { +// ^^^^^^^^ definition local filename_49 +// ^^^^^ definition local value_49 +// ^^^^^^^^^ reference local generator_26 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleOutput#files. + [filename] { +// ^^^^^^^^ reference local filename_49 + value.text +// ^^^^^ reference local value_49 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + + for (filename, value in generator2.output.files!!) { +// ^^^^^^^^ definition local filename_55 +// ^^^^^ definition local value_55 +// ^^^^^^^^^^ reference local generator2_40 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleOutput#files. + ["\(filename) -- dependency notation for k8s"] { +// ^^^^^^^^ reference local filename_55 + value.text +// ^^^^^ reference local value_55 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + + for (filename, value in generator3.output.files!!) { +// ^^^^^^^^ definition local filename_61 +// ^^^^^ definition local value_61 +// ^^^^^^^^^^ reference local generator3_44 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleOutput#files. + ["\(filename) -- different version of k8s"] { +// ^^^^^^^^ reference local filename_61 + value.text +// ^^^^^ reference local value_61 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + + ["conflicting schemas"] { + for (_, value in (generate) { +// ^^^^^ definition local value_68 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/ + sourceContents = read("fixtures/crds_conflict.yaml") +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/sourceContents. + source = "dummy://test_uri" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/source. + }.output.files!!) { +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleOutput#files. + value.text +// ^^^^^ reference local value_68 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + + ["apiGroup subdomains"] { + for (path, value in (generate) { +// ^^^^ definition local path_77 +// ^^^^^ definition local value_77 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `generate.pkl`/ + sourceContents = read("fixtures/crds_subdomain.yaml") +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/sourceContents. + source = "dummy://test_uri" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/source. + baseApiGroup = "bar" +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd 4.0.0 `tests/ModuleGenerator.pkl`/baseApiGroup. + }.output.files!!) { +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleOutput#files. + Pair(path, value.value.declaration.moduleHeader.name.parts.toList().map((it) -> it.value).join(".")) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^ reference local path_77 +// ^^^^^ reference local value_77 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#value. +// ^^ definition local it_82 +// ^^ reference local it_82 + } + } + } + diff --git a/pkl-pantrysnapshot/k8s.contrib/PklProject b/pkl-pantrysnapshot/k8s.contrib/PklProject new file mode 100755 index 00000000..2e98d441 --- /dev/null +++ b/pkl-pantrysnapshot/k8s.contrib/PklProject @@ -0,0 +1,32 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Utilities for handling k8s configuration in Pkl. + amends "../basePklProject.pkl" + + dependencies { +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 PklProject/dependencies. + ["k8s"] { + uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 PklProject/uri. + } + ["uri"] = import("../pkl.experimental.uri/PklProject") + } + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 PklProject/package. + version = "1.0.3" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 PklProject/version. + } diff --git a/pkl-pantrysnapshot/k8s.contrib/convert.pkl b/pkl-pantrysnapshot/k8s.contrib/convert.pkl new file mode 100755 index 00000000..ad72dfa3 --- /dev/null +++ b/pkl-pantrysnapshot/k8s.contrib/convert.pkl @@ -0,0 +1,829 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Converts a Kubernetes YAML manifest file to Pkl. + /// + /// Evaluating the generated Pkl file will output (an equivalent of) the original YAML. + /// Evaluating multiple generated Pkl files at once will output a single YAML stream. + /// + /// ## Prerequisites + /// + /// * The `pkl` command is [installed](https://pkl-lang.org/main/current/pkl-cli/index.html#installation). + /// + /// ## Usage + /// + /// To convert _deployment.yml_ to _deployment.pkl_, run: + /// ``` + /// pkl eval -p input=deployment.yml \ + /// -o deployment.pkl \ + /// package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib@#/convert.pkl + /// ``` + /// + /// To validate the generated Pkl file, run `pkl eval deployment.pkl`. + /// + /// ## Known limitations + /// + /// * YAML comments are not preserved. + /// * YAML aliases are inlined. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/minPklVersion. + open module k8s.contrib.convert +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ + + import "pkl:reflect" + import "pkl:yaml" + import "pkl:platform" + + import "@k8s/K8sObject.pkl" + import "@k8s/K8sResource.pkl" + import "@k8s/api/core/v1/ResourceRequirements.pkl" + import "@k8s/k8sSchema.pkl" + import "@uri/URI.pkl" + + /// The Kubernetes resources to convert. + /// + /// Each resource is an object of type [Mapping] as produced by [yaml.Parser]. + /// + /// Defaults to the resources contained in the YAML file passed with `-p input=path/to/file.yml`. + resourcesToConvert: List = +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/resourcesToConvert. +//documentation +//> The Kubernetes resources to convert. +//> +//> Each resource is an object of type [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7) as produced by [`yaml.Parser`](pkl-lsp://stdlib/yaml.pkl#L47,C7). +//> +//> Defaults to the resources contained in the YAML file passed with `-p input=path/to/file.yml`. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + new yaml.Parser { useMapping = true } +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Parser# +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/useMapping. + .parseAll(read(inputUri)) +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Parser#parseAll(). +// ^^^^^^^^ reference local inputUri_103 + .filterNonNull() as List +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + + /// Converters to be sequentially applied to [resourcesToConvert]. + /// + /// The default [resourceConverters] suffice to convert standard Kubernetes resources. + resourceConverters: Mapping Any> = new { +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/resourceConverters. +//documentation +//> Converters to be sequentially applied to [`resourcesToConvert`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/k8s.contrib/convert.pkl#L58,C1). +//> +//> The default [`resourceConverters`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/k8s.contrib/convert.pkl#L66,C1) suffice to convert standard Kubernetes resources. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + ["convert resource to conform to Pkl template"] = (resource) -> +// ^^^^^^^^ definition local resource_67 + let (template = getResourceTemplate(resource)) +// ^^^^^^^^ definition local template_68 +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/getResourceTemplate(). +// ^^^^^^^^ reference local resource_67 + let (templateType = reflect.DeclaredType(reflect.Module(template).moduleClass)) +// ^^^^^^^^^^^^ definition local templateType_69 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module(). +// ^^^^^^^^ reference local template_68 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#moduleClass. + convert(resource, templateType) +// ^^^^^^^ reference local convert_152 +// ^^^^^^^^ reference local resource_67 +// ^^^^^^^^^^^^ reference local templateType_69 + ["remove kind and apiVersion properties (set by Pkl template)"] = (resource) -> +// ^^^^^^^^ definition local resource_71 + resource.toMap().remove("apiVersion").remove("kind") |> toDynamic +// ^^^^^^^^ reference local resource_71 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#remove(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#remove(). +// ^^^^^^^^^ reference local toDynamic_119 + } + + /// Resource templates to be used for converting custom resources. + /// + /// The first [String] key is the resource's `kind`, the second its `apiVersion`. + /// + /// Example: + /// ``` + /// customResourceTemplates { + /// ["Custom"] { + /// ["v1"] = import("Custom.pkl") + /// } + /// } + /// ``` + customResourceTemplates: Mapping> +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/customResourceTemplates. +//documentation +//> Resource templates to be used for converting custom resources. +//> +//> The first [`String`](pkl-lsp://stdlib/base.pkl#L1094,C16) key is the resource's `kind`, the second its `apiVersion`. +//> +//> Example: +//> ``` +//> customResourceTemplates { +//> `"Custom"` { +//> `"v1"` = import("Custom.pkl") +//> } +//> } +//> ``` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `K8sResource.pkl`/ + + function getResourceTemplate(resource: Mapping): K8sResource = +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/getResourceTemplate(). +// ^^^^^^^^ definition local resource_89 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `K8sResource.pkl`/ + let (kind = resource["kind"]) +// ^^^^ definition local kind_90 +// ^^^^^^^^ reference local resource_89 + let (apiVersion = resource["apiVersion"]) +// ^^^^^^^^^^ definition local apiVersion_91 +// ^^^^^^^^ reference local resource_89 + doGetResourceTemplate(kind, apiVersion, k8sSchema.resourceTemplates) ?? +// ^^^^^^^^^^^^^^^^^^^^^ reference local doGetResourceTemplate_196 +// ^^^^ reference local kind_90 +// ^^^^^^^^^^ reference local apiVersion_91 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `k8sSchema.pkl`/ +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `k8sSchema.pkl`/resourceTemplates. + doGetResourceTemplate(kind, apiVersion, customResourceTemplates) ?? +// ^^^^^^^^^^^^^^^^^^^^^ reference local doGetResourceTemplate_196 +// ^^^^ reference local kind_90 +// ^^^^^^^^^^ reference local apiVersion_91 +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/customResourceTemplates. + throw("Cannot find a template for resource of kind `\(kind)`.") +// ^^^^ reference local kind_90 + + function getResourceTemplateUri(resource: Mapping): String = +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/getResourceTemplateUri(). +// ^^^^^^^^ definition local resource_96 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + reflect.Module(getResourceTemplate(resource)).uri +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module(). +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/getResourceTemplate(). +// ^^^^^^^^ reference local resource_96 +// ^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#uri. + + // below here is implementation + + input = read("prop:input") +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/input. + + local inputUri = +// ^^^^^^^^ definition local inputUri_103 + if (input.startsWith(Regex(#"\w+:"#))) input // absolute URI +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/input. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/input. + else if (input.startsWith("/")) "file://\(input)" // absolute file path +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/input. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/input. + else // relative file path + let (pwd = read("env:PWD")) +// ^^^ definition local pwd_107 + let (path = +// ^^^^ definition local path_108 + if (platform.current.operatingSystem.name == "Windows") "/\(pwd)/\(input)".replaceAll("\\", "/") +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/current. +// ^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/Platform#operatingSystem. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/OperatingSystem#name. +// ^^^ reference local pwd_107 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/input. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + else "\(pwd)/\(input)" +// ^^^ reference local pwd_107 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/input. + ) + "file://\(URI.encode(path))" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^ reference local path_108 + + function resourceConverterFn(resource) = +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/resourceConverterFn(). +// ^^^^^^^^ definition local resource_114 + resourceConverters.fold(resource, (acc, _, f) -> f.apply(acc)) +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/resourceConverters. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#fold(). +// ^^^^^^^^ reference local resource_114 +// ^^^ definition local acc_115 +// ^ definition local f_115 +// ^ reference local f_115 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^ reference local acc_115 + + local typedClass = reflect.Class(Typed) +// ^^^^^^^^^^ definition local typedClass_117 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# + + /// Preserve entry key `"default"` as property `_____default_____`, because `default` conflicts with + /// built-in [Dynamic.default]. + /// + /// We'll turn this back when rendering (see [renderConvertedValue]). + local toDynamic: (Mapping|Map) -> Dynamic = (input) -> +// ^^^^^^^^^ definition local toDynamic_119 +// documentation +// > Preserve entry key `"default"` as property `_____default_____`, because `default` conflicts with +// > built-in [`Dynamic.default`](pkl-lsp://stdlib/base.pkl#L1810,C3). +// > +// > We'll turn this back when rendering (see `renderConvertedValue`). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ definition local input_123 + if (input is Mapping) toDynamic.apply(input.toMap()) +// ^^^^^ reference local input_123 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^ reference local toDynamic_119 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^ reference local input_123 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + else + (input.toDynamic()) { +// ^^^^^ reference local input_123 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toDynamic(). + when (input.containsKey("default")) { +// ^^^^^ reference local input_123 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#containsKey(). + _____default_____ = input["default"] +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/_____default_____. +// ^^^^^ reference local input_123 + } + } + + /// Best effort conversion for union types. + /// + /// - If type is not a [Mapping] or [Listing], render as-is. + /// - If type includes [Listing] and object is [Listing], render as a [Listing]. + /// - If type includes a [Mapping], render as a [Mapping]. + /// - Otherwise, use the first remaining alternative. + local function convertUnion(value: Any, type: reflect.UnionType): Any = +// ^^^^^^^^^^^^ definition local convertUnion_132 +// documentation +// > Best effort conversion for union types. +// > +// > - If type is not a [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7) or [`Listing`](pkl-lsp://stdlib/base.pkl#L1860,C7), render as-is. +// > - If type includes [`Listing`](pkl-lsp://stdlib/base.pkl#L1860,C7) and object is [`Listing`](pkl-lsp://stdlib/base.pkl#L1860,C7), render as a [`Listing`](pkl-lsp://stdlib/base.pkl#L1860,C7). +// > - If type includes a [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7), render as a [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7). +// > - Otherwise, use the first remaining alternative. +// ^^^^^ definition local value_138 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^ definition local type_138 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + if (!(value is Mapping|Listing)) +// ^^^^^ reference local value_138 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + value +// ^^^^^ reference local value_138 + else + let (listingType = type.members.findOrNull((elem) -> elem is reflect.DeclaredType && elem.referent.reflectee == Listing)) +// ^^^^^^^^^^^ definition local listingType_142 +// ^^^^ reference local type_138 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType#members. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#findOrNull(). +// ^^^^ definition local elem_142 +// ^^^^ reference local elem_142 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# +// ^^^^ reference local elem_142 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + let (mappingType = type.members.findOrNull((elem) -> elem is reflect.DeclaredType && elem.referent.reflectee == Mapping)) +// ^^^^^^^^^^^ definition local mappingType_143 +// ^^^^ reference local type_138 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType#members. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#findOrNull(). +// ^^^^ definition local elem_143 +// ^^^^ reference local elem_143 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# +// ^^^^ reference local elem_143 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + if (value is Listing && listingType != null) +// ^^^^^ reference local value_138 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^ reference local listingType_142 + convert(value, listingType) +// ^^^^^^^ reference local convert_152 +// ^^^^^ reference local value_138 +// ^^^^^^^^^^^ reference local listingType_142 + else if (mappingType != null) +// ^^^^^^^^^^^ reference local mappingType_143 + convert(value, mappingType) +// ^^^^^^^ reference local convert_152 +// ^^^^^ reference local value_138 +// ^^^^^^^^^^^ reference local mappingType_143 + else + let (otherType = type.members.find((elem) -> elem != listingType && elem != mappingType)) +// ^^^^^^^^^ definition local otherType_149 +// ^^^^ reference local type_138 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType#members. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#find(). +// ^^^^ definition local elem_149 +// ^^^^ reference local elem_149 +// ^^^^^^^^^^^ reference local listingType_142 +// ^^^^ reference local elem_149 +// ^^^^^^^^^^^ reference local mappingType_143 + convert(value, otherType) +// ^^^^^^^ reference local convert_152 +// ^^^^^ reference local value_138 +// ^^^^^^^^^ reference local otherType_149 + + local function convert(value: Any, type: reflect.Type?): Any = +// ^^^^^^^ definition local convert_152 +// ^^^^^ definition local value_152 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^ definition local type_152 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + if (type is reflect.NullableType) +// ^^^^ reference local type_152 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType# + convert(value, type.member) +// ^^^^^^^ reference local convert_152 +// ^^^^^ reference local value_152 +// ^^^^ reference local type_152 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType#member. + else if (type is reflect.DeclaredType) +// ^^^^ reference local type_152 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# + let (referent = type.referent) +// ^^^^^^^^ definition local referent_156 +// ^^^^ reference local type_152 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. + if (value is Listing && referent.reflectee == Listing) +// ^^^^^ reference local value_152 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^ reference local referent_156 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + for (e in value) { +// ^ definition local e_159 +// ^^^^^ reference local value_152 + convert(e, type.typeArguments[0]) +// ^^^^^^^ reference local convert_152 +// ^ reference local e_159 +// ^^^^ reference local type_152 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#typeArguments. + } + } + else if (value is Mapping && referent.reflectee == Mapping) +// ^^^^^ reference local value_152 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^ reference local referent_156 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + for (k, v in value) { +// ^ definition local k_165 +// ^ definition local v_165 +// ^^^^^ reference local value_152 + [k] = convert(v, type.typeArguments[1]) +// ^ reference local k_165 +// ^^^^^^^ reference local convert_152 +// ^ reference local v_165 +// ^^^^ reference local type_152 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#typeArguments. + } + } + else if (value is Mapping && referent.reflectee == ResourceRequirements.getClass()) +// ^^^^^ reference local value_152 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^ reference local referent_156 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `api/core/v1/ResourceRequirements.pkl`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + new Dynamic { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + when (value.containsKey("requests")) { +// ^^^^^ reference local value_152 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). + requests { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/requests. + for (k, v in value["requests"]) { +// ^ definition local k_173 +// ^ definition local v_173 +// ^^^^^ reference local value_152 + [k] = convertDataSize(v) ?? v +// ^ reference local k_173 +// ^^^^^^^^^^^^^^^ reference local convertDataSize_212 +// ^ reference local v_173 +// ^ reference local v_173 + } + } + } + when (value.containsKey("limits")) { +// ^^^^^ reference local value_152 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). + limits { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/limits. + for (k, v in value["limits"]) { +// ^ definition local k_180 +// ^ definition local v_180 +// ^^^^^ reference local value_152 + [k] = convertDataSize(v) ?? v +// ^ reference local k_180 +// ^^^^^^^^^^^^^^^ reference local convertDataSize_212 +// ^ reference local v_180 +// ^ reference local v_180 + } + } + } + } + else if (value is Mapping && referent is reflect.Class && referent.isSubclassOf(typedClass)) +// ^^^^^ reference local value_152 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^ reference local referent_156 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# +// ^^^^^^^^ reference local referent_156 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#isSubclassOf(). +// ^^^^^^^^^^ reference local typedClass_117 + value +// ^^^^^ reference local value_152 + .toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + .map((k, v) -> Pair(k, convert(v, referent.properties.getOrNull(k)?.type))) |> toDynamic +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#map(). +// ^ definition local k_189 +// ^ definition local v_189 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^ reference local k_189 +// ^^^^^^^ reference local convert_152 +// ^ reference local v_189 +// ^^^^^^^^ reference local referent_156 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#properties. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#getOrNull(). +// ^ reference local k_189 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^ reference local toDynamic_119 + else value +// ^^^^^ reference local value_152 + else if (type is reflect.UnionType) +// ^^^^ reference local type_152 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType# + convertUnion(value, type) +// ^^^^^^^^^^^^ reference local convertUnion_132 +// ^^^^^ reference local value_152 +// ^^^^ reference local type_152 + else if (value is Mapping) value |> toDynamic +// ^^^^^ reference local value_152 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference local value_152 +// ^^^^^^^^^ reference local toDynamic_119 + else value +// ^^^^^ reference local value_152 + + local function doGetResourceTemplate(kind: String, apiVersion: String, templatesByKindAndVersion: Mapping): K8sResource? = +// ^^^^^^^^^^^^^^^^^^^^^ definition local doGetResourceTemplate_196 +// ^^^^ definition local kind_196 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ definition local apiVersion_196 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition local templatesByKindAndVersion_196 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `K8sResource.pkl`/ + let (templatesByVersion: Mapping? = templatesByKindAndVersion.getOrNull(kind)) +// ^^^^^^^^^^^^^^^^^^ definition local templatesByVersion_197 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference local templatesByKindAndVersion_196 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^ reference local kind_196 + if (templatesByVersion == null) +// ^^^^^^^^^^^^^^^^^^ reference local templatesByVersion_197 + null + else + let (template = templatesByVersion.getOrNull(apiVersion)) +// ^^^^^^^^ definition local template_201 +// ^^^^^^^^^^^^^^^^^^ reference local templatesByVersion_197 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^^^^^ reference local apiVersion_196 + if (template != null) +// ^^^^^^^^ reference local template_201 + template as K8sResource +// ^^^^^^^^ reference local template_201 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `K8sResource.pkl`/ + else + throw(""" + Cannot find a pantry template for version `\(apiVersion)` of resource `\(kind)`. +// ^^^^^^^^^^ reference local apiVersion_196 +// ^^^^ reference local kind_196 + Available versions: + \(templatesByVersion.keys.join("\n")) +// ^^^^^^^^^^^^^^^^^^ reference local templatesByVersion_197 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#keys. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#join(). + """) + + // https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory + local function convertDataSize(input: K8sObject.Quantity): RenderDirective? = +// ^^^^^^^^^^^^^^^ definition local convertDataSize_212 +// ^^^^^ definition local input_212 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `K8sObject.pkl`/Quantity# +// ^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RenderDirective# + let (inputString: String = if (input is Int|Float|DataSize) input.toString() else input as String) +// ^^^^^^^^^^^ definition local inputString_213 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference local input_212 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# +// ^^^^^ reference local input_212 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#toString(). +// ^^^^^ reference local input_212 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (matches = Regex(#"^(\d+(?:\.\d+)?)(k|Ki|Mi?|Gi?|Ti?|Pi?|Ei?)$"#).findMatchesIn(inputString)) +// ^^^^^^^ definition local matches_214 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex#findMatchesIn(). +// ^^^^^^^^^^^ reference local inputString_213 + if (matches.isEmpty) +// ^^^^^^^ reference local matches_214 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + null + else + let (groups = matches[0].groups) +// ^^^^^^ definition local groups_218 +// ^^^^^^^ reference local matches_214 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. + let (value = groups[1].value) +// ^^^^^ definition local value_219 +// ^^^^^^ reference local groups_218 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + let (unit = groups[2].value) +// ^^^^ definition local unit_220 +// ^^^^^^ reference local groups_218 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + // We don't have exabytes/exbibytes in Pkl, so convert down to peta/pebi + let (pklValue = if (unit.startsWith("E")) value.toInt() * 1000 else value) +// ^^^^^^^^ definition local pklValue_222 +// ^^^^ reference local unit_220 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^ reference local value_219 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). +// ^^^^^ reference local value_219 + let (pklUnit = if (unit.startsWith("E")) unit.replaceFirst("E", "P") else unit) +// ^^^^^^^ definition local pklUnit_223 +// ^^^^ reference local unit_220 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^ reference local unit_220 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^ reference local unit_220 + new RenderDirective { +// ^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RenderDirective# + text = "= \(pklValue).\(pklUnit.toLowerCase())b" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/text. +// ^^^^^^^^ reference local pklValue_222 +// ^^^^^^^ reference local pklUnit_223 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toLowerCase(). + } + + // Collects all imports, + // assigning unique import aliases if multiple versions of the same kind are used. + local importsByKindAndVersion: Map> = +// ^^^^^^^^^^^^^^^^^^^^^^^ definition local importsByKindAndVersion_230 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference local ImportInfo_267 + resourcesToConvert.fold(Map(), (imports, res) -> +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/resourcesToConvert. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^^ definition local imports_231 +// ^^^ definition local res_231 + let (importsByVersion = imports.getOrNull(res["kind"])) +// ^^^^^^^^^^^^^^^^ definition local importsByVersion_232 +// ^^^^^^^ reference local imports_231 +// ^^^ reference local res_231 + if (importsByVersion == null) +// ^^^^^^^^^^^^^^^^ reference local importsByVersion_232 + imports.put( +// ^^^^^^^ reference local imports_231 + res["kind"], +// ^^^ reference local res_231 + Map( +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + res["apiVersion"], +// ^^^ reference local res_231 + new ImportInfo { +// ^^^^^^^^^^ reference local ImportInfo_267 + resource = res +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/resource. +// ^^^ reference local res_231 + name = res["kind"] +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/name. +// ^^^ reference local res_231 + uri = getResourceTemplateUri(res) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/uri. +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/getResourceTemplateUri(). +// ^^^ reference local res_231 + isAliased = false +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/isAliased. + })) + else if (importsByVersion.containsKey(res["apiVersion"])) +// ^^^^^^^^^^^^^^^^ reference local importsByVersion_232 +// ^^^ reference local res_231 + imports +// ^^^^^^^ reference local imports_231 + else if (importsByVersion.length == 1) +// ^^^^^^^^^^^^^^^^ reference local importsByVersion_232 + let (first = importsByVersion.values.single.resource) +// ^^^^^ definition local first_247 +// ^^^^^^^^^^^^^^^^ reference local importsByVersion_232 + imports.put( +// ^^^^^^^ reference local imports_231 + res["kind"], +// ^^^ reference local res_231 + Map( +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + // for consistency, also used aliased name for first import of this kind + first["apiVersion"], createAliasedInfo(first), +// ^^^^^ reference local first_247 +// ^^^^^^^^^^^^^^^^^ reference local createAliasedInfo_260 +// ^^^^^ reference local first_247 + res["apiVersion"], createAliasedInfo(res))) +// ^^^ reference local res_231 +// ^^^^^^^^^^^^^^^^^ reference local createAliasedInfo_260 +// ^^^ reference local res_231 + else + imports.put( +// ^^^^^^^ reference local imports_231 + res["kind"], +// ^^^ reference local res_231 + importsByVersion +// ^^^^^^^^^^^^^^^^ reference local importsByVersion_232 + .put(res["apiVersion"], createAliasedInfo(res)))) +// ^^^ reference local res_231 +// ^^^^^^^^^^^^^^^^^ reference local createAliasedInfo_260 +// ^^^ reference local res_231 + + local function createAliasedInfo(res: Mapping): ImportInfo = new { +// ^^^^^^^^^^^^^^^^^ definition local createAliasedInfo_260 +// ^^^ definition local res_260 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^ reference local ImportInfo_267 + resource = res +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/resource. +// ^^^ reference local res_260 + name = "\(res["kind"])\(res["apiVersion"].split("/").last.capitalize())" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/name. +// ^^^ reference local res_260 +// ^^^ reference local res_260 + uri = getResourceTemplateUri(res) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/uri. +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/getResourceTemplateUri(). +// ^^^ reference local res_260 + isAliased = true +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/isAliased. + } + + local class ImportInfo { +// ^^^^^^^^^^ definition local ImportInfo_267 + resource: Mapping +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ImportInfo#resource. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + name: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ImportInfo#name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + uri: String +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ImportInfo#uri. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + isAliased: Boolean +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ImportInfo#isAliased. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + local function renderConvertedValue(value: Any) = +// ^^^^^^^^^^^^^^^^^^^^ definition local renderConvertedValue_274 +// ^^^^^ definition local value_274 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + new PcfRenderer {}.renderValue(value).replaceAll("_____default_____", "default") +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer# +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer#renderValue(). +// ^^^^^ reference local value_274 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/output. + local importInfos = importsByKindAndVersion.values +// ^^^^^^^^^^^ definition local importInfos_278 +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local importsByKindAndVersion_230 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. + .flatMap((it) -> it.values) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#flatMap(). +// ^^ definition local it_279 +// ^^ reference local it_279 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. + .sortWith((info1, info2) -> info1.uri < info2.uri) +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#sortWith(). +// ^^^^^ definition local info1_280 +// ^^^^^ definition local info2_280 +// ^^^^^ reference local info1_280 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ImportInfo#uri. +// ^^^^^ reference local info2_280 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ImportInfo#uri. + local textBuffer: Listing = new { +// ^^^^^^^^^^ definition local textBuffer_281 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + "import \"\(reflect.Module(K8sResource).uri)\"\n" +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-k8s/k8s 1.0.1 `K8sResource.pkl`/ +// ^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#uri. + for (importInfo in importInfos) { +// ^^^^^^^^^^ definition local importInfo_283 +// ^^^^^^^^^^^ reference local importInfos_278 + if (importInfo.isAliased) +// ^^^^^^^^^^ reference local importInfo_283 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ImportInfo#isAliased. + "import \"\(importInfo.uri)\" as \(importInfo.name)\n" +// ^^^^^^^^^^ reference local importInfo_283 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ImportInfo#uri. +// ^^^^^^^^^^ reference local importInfo_283 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ImportInfo#name. + else + "import \"\(importInfo.uri)\"\n" +// ^^^^^^^^^^ reference local importInfo_283 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ImportInfo#uri. + } + "\n" + "resources: Listing = new {" + for (resource in resourcesToConvert) { +// ^^^^^^^^ definition local resource_291 +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/resourcesToConvert. + "\n" + " new \(importsByKindAndVersion[resource["kind"]][resource["apiVersion"]].name) " +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local importsByKindAndVersion_230 +// ^^^^^^^^ reference local resource_291 +// ^^^^^^^^ reference local resource_291 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ImportInfo#name. + // would be good to be able to set base indent + for (lineIdx, line in renderConvertedValue(resourceConverterFn(resource)).split("\n")) { +// ^^^^^^^ definition local lineIdx_295 +// ^^^^ definition local line_295 +// ^^^^^^^^^^^^^^^^^^^^ reference local renderConvertedValue_274 +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/resourceConverterFn(). +// ^^^^^^^^ reference local resource_291 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). + when (lineIdx != 0) { +// ^^^^^^^ reference local lineIdx_295 + " " + } + line +// ^^^^ reference local line_295 + "\n" + } + } + "}\n\n" + """ + output { + value = resources + renderer = (K8sResource.output.renderer as YamlRenderer) { + isStream = true + } + } + """ + } + text = textBuffer.toList().join("") +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/text. +// ^^^^^^^^^^ reference local textBuffer_281 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } diff --git a/pkl-pantrysnapshot/k8s.contrib/tests/convert.pkl b/pkl-pantrysnapshot/k8s.contrib/tests/convert.pkl new file mode 100755 index 00000000..eb66018c --- /dev/null +++ b/pkl-pantrysnapshot/k8s.contrib/tests/convert.pkl @@ -0,0 +1,95 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module k8s.contrib.tests.convert +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/convert.pkl`/ + amends "pkl:test" + + import "pkl:yaml" + import "pkl:reflect" + + import "../convert.pkl" + + local absolutePathToPklPantry = reflect.Module(module).uri.replaceFirst("packages/k8s.contrib/tests/convert.pkl", "") +// ^^^^^^^^^^^^^^^^^^^^^^^ definition local absolutePathToPklPantry_24 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#uri. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). + + /// Run conversion, replacing full file import paths with paths stemming from "$pklPantryBaseDir". + /// + /// Before: + /// + /// `import "file:///User/me/work/pkl-pantry/packages/k8s/K8sObject.pkl"` + /// + /// After: + /// + /// `import "$pklPantryBaseDir/packages/k8s/K8sObject.pkl"` + local function doConvert(uri: String) = +// ^^^^^^^^^ definition local doConvert_26 +// documentation +// > Run conversion, replacing full file import paths with paths stemming from "$pklPantryBaseDir". +// > +// > Before: +// > +// > `import "file:///User/me/work/pkl-pantry/packages/k8s/K8sObject.pkl"` +// > +// > After: +// > +// > `import "$pklPantryBaseDir/packages/k8s/K8sObject.pkl"` +// ^^^ definition local uri_35 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (converter = (convert) { +// ^^^^^^^^^ definition local converter_36 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ + resourcesToConvert = new yaml.Parser { useMapping = true }.parseAll(read(uri)).filterNonNull() as List +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/convert.pkl`/resourcesToConvert. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Parser# +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/convert.pkl`/useMapping. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Parser#parseAll(). +// ^^^ reference local uri_35 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + + customResourceTemplates { +// ^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/convert.pkl`/customResourceTemplates. + ["Custom"] { + ["v1"] = import("./fixtures/CustomType.pkl") + } + } + }) + converter.output.text.replaceAll(absolutePathToPklPantry, "$pklPantryBaseDir/") +// ^^^^^^^^^ reference local converter_36 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local absolutePathToPklPantry_24 + + examples = new { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/convert.pkl`/examples. + for (file, _ in read*("fixtures/*.yml")) { +// ^^^^ definition local file_48 + [file.replaceAll(Regex(".*fixtures/"), "")] { +// ^^^^ reference local file_48 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + doConvert(file) +// ^^^^^^^^^ reference local doConvert_26 +// ^^^^ reference local file_48 + } + } + } diff --git a/pkl-pantrysnapshot/k8s.contrib/tests/fixtures/CustomType.pkl b/pkl-pantrysnapshot/k8s.contrib/tests/fixtures/CustomType.pkl new file mode 100755 index 00000000..92ee642c --- /dev/null +++ b/pkl-pantrysnapshot/k8s.contrib/tests/fixtures/CustomType.pkl @@ -0,0 +1,40 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module CustomType +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/fixtures/CustomType.pkl`/ + + extends "@k8s/K8sResource.pkl" + + fixed apiVersion = "v1" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/fixtures/CustomType.pkl`/apiVersion. + + fixed kind = "Custom" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/fixtures/CustomType.pkl`/kind. + + spec: CustomSpec? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/fixtures/CustomType.pkl`/spec. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/fixtures/CustomType.pkl`/CustomSpec# + + class CustomSpec { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/fixtures/CustomType.pkl`/CustomSpec# + field1: String? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/fixtures/CustomType.pkl`/CustomSpec#field1. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + field2: String? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `tests/fixtures/CustomType.pkl`/CustomSpec#field2. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } diff --git a/pkl-pantrysnapshot/org.apache.spark/PklProject b/pkl-pantrysnapshot/org.apache.spark/PklProject new file mode 100755 index 00000000..39ad336d --- /dev/null +++ b/pkl-pantrysnapshot/org.apache.spark/PklProject @@ -0,0 +1,36 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Definitions for [Apache Spark](https://spark.apache.org). + /// + /// Apache Spark is a distributed computing framework used for processing and analyzing large datasets. + /// It can be applied to data that is structured (like database tables) or unstructured (like log files). + /// Data can be processed one-off or on a schedule, or continuously as a stream of items from a queue. + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 PklProject/package. + version = "1.0.2" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 PklProject/version. + description = """ +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 PklProject/description. + Definitions for [Apache Spark](https://spark.apache.org). + + Apache Spark is a distributed computing framework used for processing and analyzing large datasets. + It can be applied to data that is structured (like database tables) or unstructured (like log files). + Data can be processed one-off or on a schedule, or continuously as a stream of items from a queue. + """ + } + diff --git a/pkl-pantrysnapshot/org.apache.spark/Properties.pkl b/pkl-pantrysnapshot/org.apache.spark/Properties.pkl new file mode 100755 index 00000000..737902d4 --- /dev/null +++ b/pkl-pantrysnapshot/org.apache.spark/Properties.pkl @@ -0,0 +1,5288 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + open module org.apache.spark.Properties +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/ + + extends "PropertiesBase.pkl" + + /// The number of executors to use. + /// + /// Default: (undefined) + `spark.executor.instances`: UInt? +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.instances`. +//documentation +//> The number of executors to use. +//> +//> Default: (undefined) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// The name of your application. + /// + /// This will appear in the UI and in log data. + /// + /// Default: `null` + @Reserved +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/Reserved# + @Since { version = "0.9.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.app.name`: Null? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.app.name`. +//documentation +//> The name of your application. +//> +//> This will appear in the UI and in log data. +//> +//> Default: `null` +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# + + /// Number of cores to use for the driver process, only in cluster mode. + /// + /// Default: `1` + @Since { version = "1.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.cores`: Int? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.cores`. +//documentation +//> Number of cores to use for the driver process, only in cluster mode. +//> +//> Default: `1` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Limit of total size of serialized results of all partitions for each Spark action (e.g. + /// + /// collect) in bytes. + /// Should be at least 1M, or 0 for unlimited. + /// Jobs will be aborted if the total size is above this limit. + /// Having a high limit may cause out-of-memory errors in driver (depends on spark.driver.memory and memory overhead of objects in JVM). + /// Setting a proper limit can protect the driver from out-of-memory errors. + /// + /// Default: `1.gib` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.maxResultSize`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.maxResultSize`. +//documentation +//> Limit of total size of serialized results of all partitions for each Spark action (e.g. +//> +//> collect) in bytes. +//> Should be at least 1M, or 0 for unlimited. +//> Jobs will be aborted if the total size is above this limit. +//> Having a high limit may cause out-of-memory errors in driver (depends on spark.driver.memory and memory overhead of objects in JVM). +//> Setting a proper limit can protect the driver from out-of-memory errors. +//> +//> Default: `1.gib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Amount of memory to use for the driver process, i.e. + /// + /// where SparkContext is initialized, in the same format as JVM memory strings with a size unit suffix ("k", "m", "g" or "t") (e.g. `512m`, `2g`). + /// *Note:* In client mode, this config must not be set through the `SparkConf` directly in your application, because the driver JVM has already started at that point. + /// Instead, please set this through the `--driver-memory` command line option or in your default properties file. + /// + /// Default: `1.gib` + @Since { version = "1.1.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.memory`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.memory`. +//documentation +//> Amount of memory to use for the driver process, i.e. +//> +//> where SparkContext is initialized, in the same format as JVM memory strings with a size unit suffix ("k", "m", "g" or "t") (e.g. `512m`, `2g`). +//> *Note:* In client mode, this config must not be set through the `SparkConf` directly in your application, because the driver JVM has already started at that point. +//> Instead, please set this through the `--driver-memory` command line option or in your default properties file. +//> +//> Default: `1.gib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Amount of non-heap memory to be allocated per driver process in cluster mode, in MiB unless otherwise specified. + /// + /// This is memory that accounts for things like VM overheads, interned strings, other native overheads, etc. + /// This tends to grow with the container size (typically 6-10%). + /// This option is currently supported on YARN, Mesos and Kubernetes. + /// *Note:* Non-heap memory includes off-heap memory (when `spark.memory.offHeap.enabled=true`) and memory used by other driver processes (e.g. python process that goes with a PySpark driver) and memory used by other non-driver processes running in the same container. + /// The maximum memory size of container to running driver is determined by the sum of `spark.driver.memoryOverhead` and `spark.driver.memory`. + /// + /// Default: driverMemory * spark.driver.memoryOverheadFactor, with minimum of 384 + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.memoryOverhead`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.memoryOverhead`. +//documentation +//> Amount of non-heap memory to be allocated per driver process in cluster mode, in MiB unless otherwise specified. +//> +//> This is memory that accounts for things like VM overheads, interned strings, other native overheads, etc. +//> This tends to grow with the container size (typically 6-10%). +//> This option is currently supported on YARN, Mesos and Kubernetes. +//> *Note:* Non-heap memory includes off-heap memory (when `spark.memory.offHeap.enabled=true`) and memory used by other driver processes (e.g. python process that goes with a PySpark driver) and memory used by other non-driver processes running in the same container. +//> The maximum memory size of container to running driver is determined by the sum of `spark.driver.memoryOverhead` and `spark.driver.memory`. +//> +//> Default: driverMemory * spark.driver.memoryOverheadFactor, with minimum of 384 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Fraction of driver memory to be allocated as additional non-heap memory per driver process in cluster mode. + /// + /// This is memory that accounts for things like VM overheads, interned strings, other native overheads, etc. + /// This tends to grow with the container size. + /// This value defaults to 0.10 except for Kubernetes non-JVM jobs, which defaults to 0.40. This is done as non-JVM tasks need more non-JVM heap space and such tasks commonly fail with "Memory Overhead Exceeded" errors. + /// This preempts this error with a higher default. + /// This value is ignored if `spark.driver.memoryOverhead` is set directly. + /// + /// Default: `0.1` + @Since { version = "3.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.memoryOverheadFactor`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.memoryOverheadFactor`. +//documentation +//> Fraction of driver memory to be allocated as additional non-heap memory per driver process in cluster mode. +//> +//> This is memory that accounts for things like VM overheads, interned strings, other native overheads, etc. +//> This tends to grow with the container size. +//> This value defaults to 0.10 except for Kubernetes non-JVM jobs, which defaults to 0.40. This is done as non-JVM tasks need more non-JVM heap space and such tasks commonly fail with "Memory Overhead Exceeded" errors. +//> This preempts this error with a higher default. +//> This value is ignored if `spark.driver.memoryOverhead` is set directly. +//> +//> Default: `0.1` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Amount of a particular resource type to use on the driver. + /// + /// If this is used, you must also specify the `spark.driver.resource.{resourceName}.discoveryScript` for the driver to find the resource on startup. + /// + /// Default: `0` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.resource.{resourceName}.amount`: Mapping? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.resource.{resourceName}.amount`. +//documentation +//> Amount of a particular resource type to use on the driver. +//> +//> If this is used, you must also specify the `spark.driver.resource.{resourceName}.discoveryScript` for the driver to find the resource on startup. +//> +//> Default: `0` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/ResourceName# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// A script for the driver to run to discover a particular resource type. + /// + /// This should write to STDOUT a JSON string in the format of the ResourceInformation class. + /// This has a name and an array of addresses. + /// For a client-submitted driver, discovery script must assign different resource addresses to this driver comparing to other drivers on the same host. + /// + /// Default: `null` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.resource.{resourceName}.discoveryScript`: Mapping? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.resource.{resourceName}.discoveryScript`. +//documentation +//> A script for the driver to run to discover a particular resource type. +//> +//> This should write to STDOUT a JSON string in the format of the ResourceInformation class. +//> This has a name and an array of addresses. +//> For a client-submitted driver, discovery script must assign different resource addresses to this driver comparing to other drivers on the same host. +//> +//> Default: `null` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/ResourceName# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Vendor of the resources to use for the driver. + /// + /// This option is currently only supported on Kubernetes and is actually both the vendor and domain following the Kubernetes device plugin naming convention. + /// (e.g. For GPUs on Kubernetes this config would be set to nvidia.com or amd.com) + /// + /// Default: `null` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.resource.{resourceName}.vendor`: Mapping? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.resource.{resourceName}.vendor`. +//documentation +//> Vendor of the resources to use for the driver. +//> +//> This option is currently only supported on Kubernetes and is actually both the vendor and domain following the Kubernetes device plugin naming convention. +//> (e.g. For GPUs on Kubernetes this config would be set to nvidia.com or amd.com) +//> +//> Default: `null` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/ResourceName# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Comma-separated list of class names implementing org.apache.spark.api.resource.ResourceDiscoveryPlugin to load into the application. + /// + /// This is for advanced users to replace the resource discovery class with a custom implementation. + /// Spark will try each class specified until one of them returns the resource information for that resource. + /// It tries the discovery script last if none of the plugins return information for that resource. + /// + /// Default: `"org.apache.spark.resource.ResourceDiscoveryScriptPlugin"` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.resources.discoveryPlugin`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.resources.discoveryPlugin`. +//documentation +//> Comma-separated list of class names implementing org.apache.spark.api.resource.ResourceDiscoveryPlugin to load into the application. +//> +//> This is for advanced users to replace the resource discovery class with a custom implementation. +//> Spark will try each class specified until one of them returns the resource information for that resource. +//> It tries the discovery script last if none of the plugins return information for that resource. +//> +//> Default: `"org.apache.spark.resource.ResourceDiscoveryScriptPlugin"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Amount of memory to use per executor process, in the same format as JVM memory strings with a size unit suffix ("k", "m", "g" or "t") (e.g. + /// + /// `512m`, `2g`). + /// + /// Default: `1.gib` + @Since { version = "0.7.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.memory`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.memory`. +//documentation +//> Amount of memory to use per executor process, in the same format as JVM memory strings with a size unit suffix ("k", "m", "g" or "t") (e.g. +//> +//> `512m`, `2g`). +//> +//> Default: `1.gib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// The amount of memory to be allocated to PySpark in each executor, in MiB unless otherwise specified. + /// + /// If set, PySpark memory for an executor will be limited to this amount. + /// If not set, Spark will not limit Python's memory use and it is up to the application to avoid exceeding the overhead memory space shared with other non-JVM processes. + /// When PySpark is run in YARN or Kubernetes, this memory is added to executor resource requests. + /// *Note:* This feature is dependent on Python's \`resource\` module; therefore, the behaviors and limitations are inherited. + /// For instance, Windows does not support resource limiting and actual resource is not limited on MacOS. + /// + /// Default: `null` + @Since { version = "2.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.pyspark.memory`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.pyspark.memory`. +//documentation +//> The amount of memory to be allocated to PySpark in each executor, in MiB unless otherwise specified. +//> +//> If set, PySpark memory for an executor will be limited to this amount. +//> If not set, Spark will not limit Python's memory use and it is up to the application to avoid exceeding the overhead memory space shared with other non-JVM processes. +//> When PySpark is run in YARN or Kubernetes, this memory is added to executor resource requests. +//> *Note:* This feature is dependent on Python's \`resource\` module; therefore, the behaviors and limitations are inherited. +//> For instance, Windows does not support resource limiting and actual resource is not limited on MacOS. +//> +//> Default: `null` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Amount of additional memory to be allocated per executor process, in MiB unless otherwise specified. + /// + /// This is memory that accounts for things like VM overheads, interned strings, other native overheads, etc. + /// This tends to grow with the executor size (typically 6-10%). + /// This option is currently supported on YARN and Kubernetes. + /// *Note:* Additional memory includes PySpark executor memory (when `spark.executor.pyspark.memory` is not configured) and memory used by other non-executor processes running in the same container. + /// The maximum memory size of container to running executor is determined by the sum of `spark.executor.memoryOverhead`, `spark.executor.memory`, `spark.memory.offHeap.size` and `spark.executor.pyspark.memory`. + /// + /// Default: executorMemory * spark.executor.memoryOverheadFactor, with minimum of 384 + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.memoryOverhead`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.memoryOverhead`. +//documentation +//> Amount of additional memory to be allocated per executor process, in MiB unless otherwise specified. +//> +//> This is memory that accounts for things like VM overheads, interned strings, other native overheads, etc. +//> This tends to grow with the executor size (typically 6-10%). +//> This option is currently supported on YARN and Kubernetes. +//> *Note:* Additional memory includes PySpark executor memory (when `spark.executor.pyspark.memory` is not configured) and memory used by other non-executor processes running in the same container. +//> The maximum memory size of container to running executor is determined by the sum of `spark.executor.memoryOverhead`, `spark.executor.memory`, `spark.memory.offHeap.size` and `spark.executor.pyspark.memory`. +//> +//> Default: executorMemory * spark.executor.memoryOverheadFactor, with minimum of 384 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Fraction of executor memory to be allocated as additional non-heap memory per executor process. + /// + /// This is memory that accounts for things like VM overheads, interned strings, other native overheads, etc. + /// This tends to grow with the container size. + /// This value defaults to 0.10 except for Kubernetes non-JVM jobs, which defaults to 0.40. This is done as non-JVM tasks need more non-JVM heap space and such tasks commonly fail with "Memory Overhead Exceeded" errors. + /// This preempts this error with a higher default. + /// This value is ignored if `spark.executor.memoryOverhead` is set directly. + /// + /// Default: `0.1` + @Since { version = "3.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.memoryOverheadFactor`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.memoryOverheadFactor`. +//documentation +//> Fraction of executor memory to be allocated as additional non-heap memory per executor process. +//> +//> This is memory that accounts for things like VM overheads, interned strings, other native overheads, etc. +//> This tends to grow with the container size. +//> This value defaults to 0.10 except for Kubernetes non-JVM jobs, which defaults to 0.40. This is done as non-JVM tasks need more non-JVM heap space and such tasks commonly fail with "Memory Overhead Exceeded" errors. +//> This preempts this error with a higher default. +//> This value is ignored if `spark.executor.memoryOverhead` is set directly. +//> +//> Default: `0.1` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Amount of a particular resource type to use per executor process. + /// + /// If this is used, you must also specify the `spark.executor.resource.{resourceName}.discoveryScript` for the executor to find the resource on startup. + /// + /// Default: `0` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.resource.{resourceName}.amount`: Mapping? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.resource.{resourceName}.amount`. +//documentation +//> Amount of a particular resource type to use per executor process. +//> +//> If this is used, you must also specify the `spark.executor.resource.{resourceName}.discoveryScript` for the executor to find the resource on startup. +//> +//> Default: `0` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/ResourceName# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// A script for the executor to run to discover a particular resource type. + /// + /// This should write to STDOUT a JSON string in the format of the ResourceInformation class. + /// This has a name and an array of addresses. + /// + /// Default: `null` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.resource.{resourceName}.discoveryScript`: Mapping? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.resource.{resourceName}.discoveryScript`. +//documentation +//> A script for the executor to run to discover a particular resource type. +//> +//> This should write to STDOUT a JSON string in the format of the ResourceInformation class. +//> This has a name and an array of addresses. +//> +//> Default: `null` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/ResourceName# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Vendor of the resources to use for the executors. + /// + /// This option is currently only supported on Kubernetes and is actually both the vendor and domain following the Kubernetes device plugin naming convention. + /// (e.g. For GPUs on Kubernetes this config would be set to nvidia.com or amd.com) + /// + /// Default: `null` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.resource.{resourceName}.vendor`: Mapping? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.resource.{resourceName}.vendor`. +//documentation +//> Vendor of the resources to use for the executors. +//> +//> This option is currently only supported on Kubernetes and is actually both the vendor and domain following the Kubernetes device plugin naming convention. +//> (e.g. For GPUs on Kubernetes this config would be set to nvidia.com or amd.com) +//> +//> Default: `null` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/ResourceName# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A comma-separated list of classes that implement `SparkListener`; when initializing SparkContext, instances of these classes will be created and registered with Spark's listener bus. + /// + /// If a class has a single-argument constructor that accepts a SparkConf, that constructor will be called; otherwise, a zero-argument constructor will be called. + /// If no valid constructor can be found, the SparkContext creation will fail with an exception. + /// + /// Default: `null` + @Since { version = "1.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.extraListeners`: String? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.extraListeners`. +//documentation +//> A comma-separated list of classes that implement `SparkListener`; when initializing SparkContext, instances of these classes will be created and registered with Spark's listener bus. +//> +//> If a class has a single-argument constructor that accepts a SparkConf, that constructor will be called; otherwise, a zero-argument constructor will be called. +//> If no valid constructor can be found, the SparkContext creation will fail with an exception. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Directory to use for "scratch" space in Spark, including map output files and RDDs that get stored on disk. + /// + /// This should be on a fast, local disk in your system. + /// It can also be a comma-separated list of multiple directories on different disks. + /// + ///
+ /// Note: This will be overridden by SPARK_LOCAL_DIRS (Standalone), MESOS_SANDBOX (Mesos) or + /// LOCAL_DIRS (YARN) environment variables set by the cluster manager. + /// + /// Default: `"/tmp"` + @Since { version = "0.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.local.dir`: String? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.local.dir`. +//documentation +//> Directory to use for "scratch" space in Spark, including map output files and RDDs that get stored on disk. +//> +//> This should be on a fast, local disk in your system. +//> It can also be a comma-separated list of multiple directories on different disks. +//> +//>
+//> Note: This will be overridden by SPARK_LOCAL_DIRS (Standalone), MESOS_SANDBOX (Mesos) or +//> LOCAL_DIRS (YARN) environment variables set by the cluster manager. +//> +//> Default: `"/tmp"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Logs the effective SparkConf as INFO when a SparkContext is started. + /// + /// Default: `false` + @Since { version = "0.9.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.logConf`: Boolean? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.logConf`. +//documentation +//> Logs the effective SparkConf as INFO when a SparkContext is started. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The cluster manager to connect to. + /// + /// See the list of [allowed master URL's](https://spark.apache.org/docs/latest/submitting-applications.html#master-urls). + /// + /// Default: `null` + @Since { version = "0.9.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.master`: String? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.master`. +//documentation +//> The cluster manager to connect to. +//> +//> See the list of [allowed master URL's](https://spark.apache.org/docs/latest/submitting-applications.html#master-urls). +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The deploy mode of Spark driver program, either "client" or "cluster", Which means to launch driver program locally ("client") or remotely ("cluster") on one of the nodes inside the cluster. + /// + /// Default: `null` + @Since { version = "1.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.submit.deployMode`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.submit.deployMode`. +//documentation +//> The deploy mode of Spark driver program, either "client" or "cluster", Which means to launch driver program locally ("client") or remotely ("cluster") on one of the nodes inside the cluster. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Application information that will be written into Yarn RM log/HDFS audit log when running on Yarn/HDFS. + /// + /// Its length depends on the Hadoop configuration `hadoop.caller.context.max.size`. + /// It should be concise, and typically can have up to 50 characters. + /// + /// Default: `null` + @Since { version = "2.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.log.callerContext`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.log.callerContext`. +//documentation +//> Application information that will be written into Yarn RM log/HDFS audit log when running on Yarn/HDFS. +//> +//> Its length depends on the Hadoop configuration `hadoop.caller.context.max.size`. +//> It should be concise, and typically can have up to 50 characters. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// If true, restarts the driver automatically if it fails with a non-zero exit status. + /// + /// Only has effect in Spark standalone mode or Mesos cluster deploy mode. + /// + /// Default: `false` + @Since { version = "1.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.supervise`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.supervise`. +//documentation +//> If true, restarts the driver automatically if it fails with a non-zero exit status. +//> +//> Only has effect in Spark standalone mode or Mesos cluster deploy mode. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Base directory in which Spark driver logs are synced, if `spark.driver.log.persistToDfs.enabled` is true. + /// + /// Within this base directory, each application logs the driver logs to an application specific file. + /// Users may want to set this to a unified location like an HDFS directory so driver log files can be persisted for later usage. + /// This directory should allow any Spark user to read/write files and the Spark History Server user to delete files. + /// Additionally, older logs from this directory are cleaned by the [Spark History Server](https://spark.apache.org/docs/latest/monitoring.html#spark-history-server-configuration-options) if `spark.history.fs.driverlog.cleaner.enabled` is true and, if they are older than max age configured by setting `spark.history.fs.driverlog.cleaner.maxAge`. + /// + /// Default: `null` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.log.dfsDir`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.log.dfsDir`. +//documentation +//> Base directory in which Spark driver logs are synced, if `spark.driver.log.persistToDfs.enabled` is true. +//> +//> Within this base directory, each application logs the driver logs to an application specific file. +//> Users may want to set this to a unified location like an HDFS directory so driver log files can be persisted for later usage. +//> This directory should allow any Spark user to read/write files and the Spark History Server user to delete files. +//> Additionally, older logs from this directory are cleaned by the [Spark History Server](https://spark.apache.org/docs/latest/monitoring.html#spark-history-server-configuration-options) if `spark.history.fs.driverlog.cleaner.enabled` is true and, if they are older than max age configured by setting `spark.history.fs.driverlog.cleaner.maxAge`. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// If true, spark application running in client mode will write driver logs to a persistent storage, configured in `spark.driver.log.dfsDir`. + /// + /// If `spark.driver.log.dfsDir` is not configured, driver logs will not be persisted. + /// Additionally, enable the cleaner by setting `spark.history.fs.driverlog.cleaner.enabled` to true in [Spark History Server](https://spark.apache.org/docs/latest/monitoring.html#spark-history-server-configuration-options). + /// + /// Default: `false` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.log.persistToDfs.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.log.persistToDfs.enabled`. +//documentation +//> If true, spark application running in client mode will write driver logs to a persistent storage, configured in `spark.driver.log.dfsDir`. +//> +//> If `spark.driver.log.dfsDir` is not configured, driver logs will not be persisted. +//> Additionally, enable the cleaner by setting `spark.history.fs.driverlog.cleaner.enabled` to true in [Spark History Server](https://spark.apache.org/docs/latest/monitoring.html#spark-history-server-configuration-options). +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The layout for the driver logs that are synced to `spark.driver.log.dfsDir`. + /// + /// If this is not configured, it uses the layout for the first appender defined in log4j2.properties. + /// If that is also not configured, driver logs use the default layout. + /// + /// Default: %d{yy/MM/dd HH:mm:ss.SSS} %t %p %c{1}: %m%n%ex + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.log.layout`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.log.layout`. +//documentation +//> The layout for the driver logs that are synced to `spark.driver.log.dfsDir`. +//> +//> If this is not configured, it uses the layout for the first appender defined in log4j2.properties. +//> If that is also not configured, driver logs use the default layout. +//> +//> Default: %d{yy/MM/dd HH:mm:ss.SSS} %t %p %c{1}: %m%n%ex +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Whether to allow driver logs to use erasure coding. + /// + /// On HDFS, erasure coded files will not update as quickly as regular replicated files, so they make take longer to reflect changes written by the application. + /// Note that even if this is true, Spark will still not force the file to use erasure coding, it will simply use file system defaults. + /// + /// Default: `false` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.log.allowErasureCoding`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.log.allowErasureCoding`. +//documentation +//> Whether to allow driver logs to use erasure coding. +//> +//> On HDFS, erasure coded files will not update as quickly as regular replicated files, so they make take longer to reflect changes written by the application. +//> Note that even if this is true, Spark will still not force the file to use erasure coding, it will simply use file system defaults. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Extra classpath entries to prepend to the classpath of the driver. + /// + /// + ///
Note: In client mode, this config must not be set through the SparkConf + /// directly in your application, because the driver JVM has already started at that point. + /// Instead, please set this through the --driver-class-path command line option or in + /// your default properties file. + /// + /// Default: `null` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.extraClassPath`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.extraClassPath`. +//documentation +//> Extra classpath entries to prepend to the classpath of the driver. +//> +//> +//>
Note: In client mode, this config must not be set through the SparkConf +//> directly in your application, because the driver JVM has already started at that point. +//> Instead, please set this through the --driver-class-path command line option or in +//> your default properties file. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A string of default JVM options to prepend to `spark.driver.extraJavaOptions`. + /// + /// This is intended to be set by administrators. + /// + /// For instance, GC settings or other logging. + /// Note that it is illegal to set maximum heap size (-Xmx) settings with this option. + /// Maximum heap + /// size settings can be set with spark.driver.memory in the cluster mode and through + /// the --driver-memory command line option in the client mode. + /// + ///
Note: In client mode, this config must not be set through the SparkConf + /// directly in your application, because the driver JVM has already started at that point. + /// Instead, please set this through the --driver-java-options command line option or in + /// your default properties file. + /// + /// Default: `null` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.defaultJavaOptions`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.defaultJavaOptions`. +//documentation +//> A string of default JVM options to prepend to `spark.driver.extraJavaOptions`. +//> +//> This is intended to be set by administrators. +//> +//> For instance, GC settings or other logging. +//> Note that it is illegal to set maximum heap size (-Xmx) settings with this option. +//> Maximum heap +//> size settings can be set with spark.driver.memory in the cluster mode and through +//> the --driver-memory command line option in the client mode. +//> +//>
Note: In client mode, this config must not be set through the SparkConf +//> directly in your application, because the driver JVM has already started at that point. +//> Instead, please set this through the --driver-java-options command line option or in +//> your default properties file. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A string of extra JVM options to pass to the driver. + /// + /// This is intended to be set by users. + /// + /// For instance, GC settings or other logging. + /// Note that it is illegal to set maximum heap size (-Xmx) settings with this option. + /// Maximum heap + /// size settings can be set with spark.driver.memory in the cluster mode and through + /// the --driver-memory command line option in the client mode. + /// + ///
Note: In client mode, this config must not be set through the SparkConf + /// directly in your application, because the driver JVM has already started at that point. + /// Instead, please set this through the --driver-java-options command line option or in + /// your default properties file. + /// + /// spark.driver.defaultJavaOptions will be prepended to this configuration. + /// + /// Default: `null` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.extraJavaOptions`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.extraJavaOptions`. +//documentation +//> A string of extra JVM options to pass to the driver. +//> +//> This is intended to be set by users. +//> +//> For instance, GC settings or other logging. +//> Note that it is illegal to set maximum heap size (-Xmx) settings with this option. +//> Maximum heap +//> size settings can be set with spark.driver.memory in the cluster mode and through +//> the --driver-memory command line option in the client mode. +//> +//>
Note: In client mode, this config must not be set through the SparkConf +//> directly in your application, because the driver JVM has already started at that point. +//> Instead, please set this through the --driver-java-options command line option or in +//> your default properties file. +//> +//> spark.driver.defaultJavaOptions will be prepended to this configuration. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Set a special library path to use when launching the driver JVM. + /// + /// + ///
Note: In client mode, this config must not be set through the SparkConf + /// directly in your application, because the driver JVM has already started at that point. + /// Instead, please set this through the --driver-library-path command line option or in + /// your default properties file. + /// + /// Default: `null` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.extraLibraryPath`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.extraLibraryPath`. +//documentation +//> Set a special library path to use when launching the driver JVM. +//> +//> +//>
Note: In client mode, this config must not be set through the SparkConf +//> directly in your application, because the driver JVM has already started at that point. +//> Instead, please set this through the --driver-library-path command line option or in +//> your default properties file. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// (Experimental) Whether to give user-added jars precedence over Spark's own jars when loading classes in the driver. + /// + /// This feature can be used to mitigate conflicts between Spark's dependencies and user dependencies. + /// It is currently an experimental feature. + /// + /// This is used in cluster mode only. + /// + /// Default: `false` + @Since { version = "1.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.userClassPathFirst`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.userClassPathFirst`. +//documentation +//> (Experimental) Whether to give user-added jars precedence over Spark's own jars when loading classes in the driver. +//> +//> This feature can be used to mitigate conflicts between Spark's dependencies and user dependencies. +//> It is currently an experimental feature. +//> +//> This is used in cluster mode only. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Extra classpath entries to prepend to the classpath of executors. + /// + /// This exists primarily for backwards-compatibility with older versions of Spark. + /// Users typically should not need to set this option. + /// + /// Default: `null` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.extraClassPath`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.extraClassPath`. +//documentation +//> Extra classpath entries to prepend to the classpath of executors. +//> +//> This exists primarily for backwards-compatibility with older versions of Spark. +//> Users typically should not need to set this option. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A string of default JVM options to prepend to `spark.executor.extraJavaOptions`. + /// + /// This is intended to be set by administrators. + /// + /// For instance, GC settings or other logging. + /// Note that it is illegal to set Spark properties or maximum heap size (-Xmx) settings with this + /// option. + /// Spark properties should be set using a SparkConf object or the spark-defaults.conf file + /// used with the spark-submit script. + /// Maximum heap size settings can be set with spark.executor.memory. + /// + /// The following symbols, if present will be interpolated: {{APP_ID}} will be replaced by + /// application ID and {{EXECUTOR_ID}} will be replaced by executor ID. For example, to enable + /// verbose gc logging to a file named for the executor ID of the app in /tmp, pass a 'value' of: + /// -verbose:gc -Xloggc:/tmp/{{APP_ID}}-{{EXECUTOR_ID}}.gc + /// + /// Default: `null` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.defaultJavaOptions`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.defaultJavaOptions`. +//documentation +//> A string of default JVM options to prepend to `spark.executor.extraJavaOptions`. +//> +//> This is intended to be set by administrators. +//> +//> For instance, GC settings or other logging. +//> Note that it is illegal to set Spark properties or maximum heap size (-Xmx) settings with this +//> option. +//> Spark properties should be set using a SparkConf object or the spark-defaults.conf file +//> used with the spark-submit script. +//> Maximum heap size settings can be set with spark.executor.memory. +//> +//> The following symbols, if present will be interpolated: {{APP_ID}} will be replaced by +//> application ID and {{EXECUTOR_ID}} will be replaced by executor ID. For example, to enable +//> verbose gc logging to a file named for the executor ID of the app in /tmp, pass a 'value' of: +//> -verbose:gc -Xloggc:/tmp/{{APP_ID}}-{{EXECUTOR_ID}}.gc +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A string of extra JVM options to pass to executors. + /// + /// This is intended to be set by users. + /// + /// For instance, GC settings or other logging. + /// Note that it is illegal to set Spark properties or maximum heap size (-Xmx) settings with this + /// option. + /// Spark properties should be set using a SparkConf object or the spark-defaults.conf file + /// used with the spark-submit script. + /// Maximum heap size settings can be set with spark.executor.memory. + /// + /// The following symbols, if present will be interpolated: {{APP_ID}} will be replaced by + /// application ID and {{EXECUTOR_ID}} will be replaced by executor ID. For example, to enable + /// verbose gc logging to a file named for the executor ID of the app in /tmp, pass a 'value' of: + /// -verbose:gc -Xloggc:/tmp/{{APP_ID}}-{{EXECUTOR_ID}}.gc + /// + /// spark.executor.defaultJavaOptions will be prepended to this configuration. + /// + /// Default: `null` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.extraJavaOptions`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.extraJavaOptions`. +//documentation +//> A string of extra JVM options to pass to executors. +//> +//> This is intended to be set by users. +//> +//> For instance, GC settings or other logging. +//> Note that it is illegal to set Spark properties or maximum heap size (-Xmx) settings with this +//> option. +//> Spark properties should be set using a SparkConf object or the spark-defaults.conf file +//> used with the spark-submit script. +//> Maximum heap size settings can be set with spark.executor.memory. +//> +//> The following symbols, if present will be interpolated: {{APP_ID}} will be replaced by +//> application ID and {{EXECUTOR_ID}} will be replaced by executor ID. For example, to enable +//> verbose gc logging to a file named for the executor ID of the app in /tmp, pass a 'value' of: +//> -verbose:gc -Xloggc:/tmp/{{APP_ID}}-{{EXECUTOR_ID}}.gc +//> +//> spark.executor.defaultJavaOptions will be prepended to this configuration. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Set a special library path to use when launching executor JVM's. + /// + /// Default: `null` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.extraLibraryPath`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.extraLibraryPath`. +//documentation +//> Set a special library path to use when launching executor JVM's. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Sets the number of latest rolling log files that are going to be retained by the system. + /// + /// Older log files will be deleted. + /// Disabled by default. + /// + /// Default: `null` + @Since { version = "1.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.logs.rolling.maxRetainedFiles`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.logs.rolling.maxRetainedFiles`. +//documentation +//> Sets the number of latest rolling log files that are going to be retained by the system. +//> +//> Older log files will be deleted. +//> Disabled by default. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Enable executor log compression. + /// + /// If it is enabled, the rolled executor logs will be compressed. + /// Disabled by default. + /// + /// Default: `false` + @Since { version = "2.0.2" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.logs.rolling.enableCompression`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.logs.rolling.enableCompression`. +//documentation +//> Enable executor log compression. +//> +//> If it is enabled, the rolled executor logs will be compressed. +//> Disabled by default. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Set the max size of the file in bytes by which the executor logs will be rolled over. + /// + /// Rolling is disabled by default. + /// See `spark.executor.logs.rolling.maxRetainedFiles` for automatic cleaning of old logs. + /// + /// Default: `null` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.logs.rolling.maxSize`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.logs.rolling.maxSize`. +//documentation +//> Set the max size of the file in bytes by which the executor logs will be rolled over. +//> +//> Rolling is disabled by default. +//> See `spark.executor.logs.rolling.maxRetainedFiles` for automatic cleaning of old logs. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Set the strategy of rolling of executor logs. + /// + /// By default it is disabled. + /// It can be set to "time" (time-based rolling) or "size" (size-based rolling). + /// For "time", use `spark.executor.logs.rolling.time.interval` to set the rolling interval. + /// For "size", use `spark.executor.logs.rolling.maxSize` to set the maximum file size for rolling. + /// + /// Default: `null` + @Since { version = "1.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.logs.rolling.strategy`: UInt? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.logs.rolling.strategy`. +//documentation +//> Set the strategy of rolling of executor logs. +//> +//> By default it is disabled. +//> It can be set to "time" (time-based rolling) or "size" (size-based rolling). +//> For "time", use `spark.executor.logs.rolling.time.interval` to set the rolling interval. +//> For "size", use `spark.executor.logs.rolling.maxSize` to set the maximum file size for rolling. +//> +//> Default: `null` +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Set the time interval by which the executor logs will be rolled over. + /// + /// Rolling is disabled by default. + /// Valid values are `daily`, `hourly`, `minutely` or any interval in seconds. + /// See `spark.executor.logs.rolling.maxRetainedFiles` for automatic cleaning of old logs. + /// + /// Default: `"daily"` + @Since { version = "1.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.logs.rolling.time.interval`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.logs.rolling.time.interval`. +//documentation +//> Set the time interval by which the executor logs will be rolled over. +//> +//> Rolling is disabled by default. +//> Valid values are `daily`, `hourly`, `minutely` or any interval in seconds. +//> See `spark.executor.logs.rolling.maxRetainedFiles` for automatic cleaning of old logs. +//> +//> Default: `"daily"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// (Experimental) Same functionality as `spark.driver.userClassPathFirst`, but applied to executor instances. + /// + /// Default: `false` + @Since { version = "1.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.userClassPathFirst`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.userClassPathFirst`. +//documentation +//> (Experimental) Same functionality as `spark.driver.userClassPathFirst`, but applied to executor instances. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Add the environment variable specified by `EnvironmentVariableName` to the Executor process. + /// + /// The user can specify multiple of these to set multiple environment variables. + /// + /// Default: `null` + @Since { version = "0.9.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executorEnv.[EnvironmentVariableName]`: Mapping? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executorEnv.[EnvironmentVariableName]`. +//documentation +//> Add the environment variable specified by `EnvironmentVariableName` to the Executor process. +//> +//> The user can specify multiple of these to set multiple environment variables. +//> +//> Default: `null` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Regex to decide which Spark configuration properties and environment variables in driver and executor environments contain sensitive information. + /// + /// When this regex matches a property key or value, the value is redacted from the environment UI and various logs like YARN and event logs. + /// + /// Default: `"(?i)secret|password|token"` + @Since { version = "2.1.2" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.redaction.regex`: String? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.redaction.regex`. +//documentation +//> Regex to decide which Spark configuration properties and environment variables in driver and executor environments contain sensitive information. +//> +//> When this regex matches a property key or value, the value is redacted from the environment UI and various logs like YARN and event logs. +//> +//> Default: `"(?i)secret|password|token"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Enable profiling in Python worker, the profile result will show up by `sc.show_profiles()`, or it will be displayed before the driver exits. + /// + /// It also can be dumped into disk by `sc.dump_profiles(path)`. + /// If some of the profile results had been displayed manually, they will not be displayed automatically before driver exiting. + /// + /// By default the pyspark.profiler.BasicProfiler will be used, but this can be overridden by + /// passing a profiler class in as a parameter to the SparkContext constructor. + /// + /// Default: `false` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.python.profile`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.python.profile`. +//documentation +//> Enable profiling in Python worker, the profile result will show up by `sc.show_profiles()`, or it will be displayed before the driver exits. +//> +//> It also can be dumped into disk by `sc.dump_profiles(path)`. +//> If some of the profile results had been displayed manually, they will not be displayed automatically before driver exiting. +//> +//> By default the pyspark.profiler.BasicProfiler will be used, but this can be overridden by +//> passing a profiler class in as a parameter to the SparkContext constructor. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The directory which is used to dump the profile result before driver exiting. + /// + /// The results will be dumped as separated file for each RDD. + /// They can be loaded by `pstats.Stats()`. If this is specified, the profile result will not be displayed automatically. + /// + /// Default: `null` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.python.profile.dump`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.python.profile.dump`. +//documentation +//> The directory which is used to dump the profile result before driver exiting. +//> +//> The results will be dumped as separated file for each RDD. +//> They can be loaded by `pstats.Stats()`. If this is specified, the profile result will not be displayed automatically. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Amount of memory to use per python worker process during aggregation, in the same format as JVM memory strings with a size unit suffix ("k", "m", "g" or "t") (e.g. + /// + /// `512m`, `2g`). + /// If the memory used during aggregation goes above this amount, it will spill the data into disks. + /// + /// Default: `512.mib` + @Since { version = "1.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.python.worker.memory`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.python.worker.memory`. +//documentation +//> Amount of memory to use per python worker process during aggregation, in the same format as JVM memory strings with a size unit suffix ("k", "m", "g" or "t") (e.g. +//> +//> `512m`, `2g`). +//> If the memory used during aggregation goes above this amount, it will spill the data into disks. +//> +//> Default: `512.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Reuse Python worker or not. + /// + /// If yes, it will use a fixed number of Python workers, does not need to fork() a Python process for every task. + /// It will be very useful if there is a large broadcast, then the broadcast will not need to be transferred from JVM to Python worker for every task. + /// + /// Default: `true` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.python.worker.reuse`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.python.worker.reuse`. +//documentation +//> Reuse Python worker or not. +//> +//> If yes, it will use a fixed number of Python workers, does not need to fork() a Python process for every task. +//> It will be very useful if there is a large broadcast, then the broadcast will not need to be transferred from JVM to Python worker for every task. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Comma-separated list of files to be placed in the working directory of each executor. + /// + /// Globs are allowed. + /// + /// Default: `null` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.files`: String? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.files`. +//documentation +//> Comma-separated list of files to be placed in the working directory of each executor. +//> +//> Globs are allowed. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Comma-separated list of .zip, .egg, or .py files to place on the PYTHONPATH for Python apps. + /// + /// Globs are allowed. + /// + /// Default: `null` + @Since { version = "1.0.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.submit.pyFiles`: String? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.submit.pyFiles`. +//documentation +//> Comma-separated list of .zip, .egg, or .py files to place on the PYTHONPATH for Python apps. +//> +//> Globs are allowed. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Comma-separated list of jars to include on the driver and executor classpaths. + /// + /// Globs are allowed. + /// + /// Default: `null` + @Since { version = "0.9.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.jars`: String? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.jars`. +//documentation +//> Comma-separated list of jars to include on the driver and executor classpaths. +//> +//> Globs are allowed. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Comma-separated list of Maven coordinates of jars to include on the driver and executor classpaths. + /// + /// The coordinates should be groupId:artifactId:version. + /// If `spark.jars.ivySettings` is given artifacts will be resolved according to the configuration in the file, otherwise artifacts will be searched for in the local maven repo, then maven central and finally any additional remote repositories given by the command-line option `--repositories`. + /// For more details, see [Advanced Dependency Management](https://spark.apache.org/docs/latest/submitting-applications.html#advanced-dependency-management). + /// + /// Default: `null` + @Since { version = "1.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.jars.packages`: String? +//^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.jars.packages`. +//documentation +//> Comma-separated list of Maven coordinates of jars to include on the driver and executor classpaths. +//> +//> The coordinates should be groupId:artifactId:version. +//> If `spark.jars.ivySettings` is given artifacts will be resolved according to the configuration in the file, otherwise artifacts will be searched for in the local maven repo, then maven central and finally any additional remote repositories given by the command-line option `--repositories`. +//> For more details, see [Advanced Dependency Management](https://spark.apache.org/docs/latest/submitting-applications.html#advanced-dependency-management). +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Comma-separated list of groupId:artifactId, to exclude while resolving the dependencies provided in `spark.jars.packages` to avoid dependency conflicts. + /// + /// Default: `null` + @Since { version = "1.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.jars.excludes`: String? +//^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.jars.excludes`. +//documentation +//> Comma-separated list of groupId:artifactId, to exclude while resolving the dependencies provided in `spark.jars.packages` to avoid dependency conflicts. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Path to specify the Ivy user directory, used for the local Ivy cache and package files from `spark.jars.packages`. + /// + /// This will override the Ivy property `ivy.default.ivy.user.dir` which defaults to \~/.ivy2. + /// + /// Default: `null` + @Since { version = "1.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.jars.ivy`: String? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.jars.ivy`. +//documentation +//> Path to specify the Ivy user directory, used for the local Ivy cache and package files from `spark.jars.packages`. +//> +//> This will override the Ivy property `ivy.default.ivy.user.dir` which defaults to \~/.ivy2. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Path to an Ivy settings file to customize resolution of jars specified using `spark.jars.packages` instead of the built-in defaults, such as maven central. + /// + /// Additional repositories given by the command-line option `--repositories` or `spark.jars.repositories` will also be included. + /// Useful for allowing Spark to resolve artifacts from behind a firewall e.g. via an in-house artifact server like Artifactory. + /// Details on the settings file format can be found at [Settings Files](http://ant.apache.org/ivy/history/latest-milestone/settings.html). + /// Only paths with `file://` scheme are supported. + /// Paths without a scheme are assumed to have a `file://` scheme. + /// + /// + ///
+ /// + /// When running in YARN cluster mode, this file will also be localized to the remote driver for dependency resolution within `SparkContext#addJar` + /// + /// Default: `null` + @Since { version = "2.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.jars.ivySettings`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.jars.ivySettings`. +//documentation +//> Path to an Ivy settings file to customize resolution of jars specified using `spark.jars.packages` instead of the built-in defaults, such as maven central. +//> +//> Additional repositories given by the command-line option `--repositories` or `spark.jars.repositories` will also be included. +//> Useful for allowing Spark to resolve artifacts from behind a firewall e.g. via an in-house artifact server like Artifactory. +//> Details on the settings file format can be found at [Settings Files](http://ant.apache.org/ivy/history/latest-milestone/settings.html). +//> Only paths with `file://` scheme are supported. +//> Paths without a scheme are assumed to have a `file://` scheme. +//> +//> +//>
+//> +//> When running in YARN cluster mode, this file will also be localized to the remote driver for dependency resolution within `SparkContext#addJar` +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Comma-separated list of additional remote repositories to search for the maven coordinates given with `--packages` or `spark.jars.packages`. + /// + /// Default: `null` + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.jars.repositories`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.jars.repositories`. +//documentation +//> Comma-separated list of additional remote repositories to search for the maven coordinates given with `--packages` or `spark.jars.packages`. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Comma-separated list of archives to be extracted into the working directory of each executor. + /// + /// .jar, .tar.gz, .tgz and .zip are supported. + /// You can specify the directory name to unpack via adding `#` after the file name to unpack, for example, `file.zip#directory`. + /// This configuration is experimental. + /// + /// Default: `null` + @Since { version = "3.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.archives`: String? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.archives`. +//documentation +//> Comma-separated list of archives to be extracted into the working directory of each executor. +//> +//> .jar, .tar.gz, .tgz and .zip are supported. +//> You can specify the directory name to unpack via adding `#` after the file name to unpack, for example, `file.zip#directory`. +//> This configuration is experimental. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Python binary executable to use for PySpark in driver. + /// + /// (default is `spark.pyspark.python`) + /// + /// Default: `null` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.pyspark.driver.python`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.pyspark.driver.python`. +//documentation +//> Python binary executable to use for PySpark in driver. +//> +//> (default is `spark.pyspark.python`) +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Python binary executable to use for PySpark in both driver and executors. + /// + /// Default: `null` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.pyspark.python`: String? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.pyspark.python`. +//documentation +//> Python binary executable to use for PySpark in both driver and executors. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Maximum size of map outputs to fetch simultaneously from each reduce task, in MiB unless otherwise specified. + /// + /// Since each output requires us to create a buffer to receive it, this represents a fixed memory overhead per reduce task, so keep it small unless you have a large amount of memory. + /// + /// Default: `48.mib` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.reducer.maxSizeInFlight`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.reducer.maxSizeInFlight`. +//documentation +//> Maximum size of map outputs to fetch simultaneously from each reduce task, in MiB unless otherwise specified. +//> +//> Since each output requires us to create a buffer to receive it, this represents a fixed memory overhead per reduce task, so keep it small unless you have a large amount of memory. +//> +//> Default: `48.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// This configuration limits the number of remote requests to fetch blocks at any given point. + /// + /// When the number of hosts in the cluster increase, it might lead to very large number of inbound connections to one or more nodes, causing the workers to fail under load. + /// By allowing it to limit the number of fetch requests, this scenario can be mitigated. + /// + /// Default: `2147483647` + @Since { version = "2.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.reducer.maxReqsInFlight`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.reducer.maxReqsInFlight`. +//documentation +//> This configuration limits the number of remote requests to fetch blocks at any given point. +//> +//> When the number of hosts in the cluster increase, it might lead to very large number of inbound connections to one or more nodes, causing the workers to fail under load. +//> By allowing it to limit the number of fetch requests, this scenario can be mitigated. +//> +//> Default: `2147483647` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// This configuration limits the number of remote blocks being fetched per reduce task from a given host port. + /// + /// When a large number of blocks are being requested from a given address in a single fetch or simultaneously, this could crash the serving executor or Node Manager. + /// This is especially useful to reduce the load on the Node Manager when external shuffle is enabled. + /// You can mitigate this issue by setting it to a lower value. + /// + /// Default: `2147483647` + @Since { version = "2.2.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.reducer.maxBlocksInFlightPerAddress`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.reducer.maxBlocksInFlightPerAddress`. +//documentation +//> This configuration limits the number of remote blocks being fetched per reduce task from a given host port. +//> +//> When a large number of blocks are being requested from a given address in a single fetch or simultaneously, this could crash the serving executor or Node Manager. +//> This is especially useful to reduce the load on the Node Manager when external shuffle is enabled. +//> You can mitigate this issue by setting it to a lower value. +//> +//> Default: `2147483647` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Whether to compress map output files. + /// + /// Generally a good idea. + /// Compression will use `spark.io.compression.codec`. + /// + /// Default: `true` + @Since { version = "0.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.compress`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.compress`. +//documentation +//> Whether to compress map output files. +//> +//> Generally a good idea. +//> Compression will use `spark.io.compression.codec`. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Size of the in-memory buffer for each shuffle file output stream, in KiB unless otherwise specified. + /// + /// These buffers reduce the number of disk seeks and system calls made in creating intermediate shuffle files. + /// + /// Default: `32.kib` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.file.buffer`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.file.buffer`. +//documentation +//> Size of the in-memory buffer for each shuffle file output stream, in KiB unless otherwise specified. +//> +//> These buffers reduce the number of disk seeks and system calls made in creating intermediate shuffle files. +//> +//> Default: `32.kib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// (Netty only) Fetches that fail due to IO-related exceptions are automatically retried if this is set to a non-zero value. + /// + /// This retry logic helps stabilize large shuffles in the face of long GC pauses or transient network connectivity issues. + /// + /// Default: `3` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.io.maxRetries`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.io.maxRetries`. +//documentation +//> (Netty only) Fetches that fail due to IO-related exceptions are automatically retried if this is set to a non-zero value. +//> +//> This retry logic helps stabilize large shuffles in the face of long GC pauses or transient network connectivity issues. +//> +//> Default: `3` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// (Netty only) Connections between hosts are reused in order to reduce connection buildup for large clusters. + /// + /// For clusters with many hard disks and few hosts, this may result in insufficient concurrency to saturate all disks, and so users may consider increasing this value. + /// + /// Default: `1` + @Since { version = "1.2.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.io.numConnectionsPerPeer`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.io.numConnectionsPerPeer`. +//documentation +//> (Netty only) Connections between hosts are reused in order to reduce connection buildup for large clusters. +//> +//> For clusters with many hard disks and few hosts, this may result in insufficient concurrency to saturate all disks, and so users may consider increasing this value. +//> +//> Default: `1` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// (Netty only) Off-heap buffers are used to reduce garbage collection during shuffle and cache block transfer. + /// + /// For environments where off-heap memory is tightly limited, users may wish to turn this off to force all allocations from Netty to be on-heap. + /// + /// Default: `true` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.io.preferDirectBufs`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.io.preferDirectBufs`. +//documentation +//> (Netty only) Off-heap buffers are used to reduce garbage collection during shuffle and cache block transfer. +//> +//> For environments where off-heap memory is tightly limited, users may wish to turn this off to force all allocations from Netty to be on-heap. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// (Netty only) How long to wait between retries of fetches. + /// + /// The maximum delay caused by retrying is 15 seconds by default, calculated as `maxRetries * retryWait`. + /// + /// Default: `5.s` + @Since { version = "1.2.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.io.retryWait`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.io.retryWait`. +//documentation +//> (Netty only) How long to wait between retries of fetches. +//> +//> The maximum delay caused by retrying is 15 seconds by default, calculated as `maxRetries * retryWait`. +//> +//> Default: `5.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Length of the accept queue for the shuffle service. + /// + /// For large applications, this value may need to be increased, so that incoming connections are not dropped if the service cannot keep up with a large number of connections arriving in a short period of time. + /// This needs to be configured wherever the shuffle service itself is running, which may be outside of the application (see `spark.shuffle.service.enabled` option below). + /// If set below 1, will fallback to OS default defined by Netty's `io.netty.util.NetUtil#SOMAXCONN`. + /// + /// Default: `-1` + @Since { version = "1.1.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.io.backLog`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.io.backLog`. +//documentation +//> Length of the accept queue for the shuffle service. +//> +//> For large applications, this value may need to be increased, so that incoming connections are not dropped if the service cannot keep up with a large number of connections arriving in a short period of time. +//> This needs to be configured wherever the shuffle service itself is running, which may be outside of the application (see `spark.shuffle.service.enabled` option below). +//> If set below 1, will fallback to OS default defined by Netty's `io.netty.util.NetUtil#SOMAXCONN`. +//> +//> Default: `-1` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Timeout for the established connections between shuffle servers and clients to be marked as idled and closed if there are still outstanding fetch requests but no traffic no the channel for at least \`connectionTimeout\`. + /// + /// Default: value of spark.network.timeout + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.io.connectionTimeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.io.connectionTimeout`. +//documentation +//> Timeout for the established connections between shuffle servers and clients to be marked as idled and closed if there are still outstanding fetch requests but no traffic no the channel for at least \`connectionTimeout\`. +//> +//> Default: value of spark.network.timeout +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Enables the external shuffle service. + /// + /// This service preserves the shuffle files written by executors e.g. so that executors can be safely removed, or so that shuffle fetches can continue in the event of executor failure. + /// The external shuffle service must be set up in order to enable it. See [dynamic allocation configuration and setup documentation](https://spark.apache.org/docs/latest/job-scheduling.html#configuration-and-setup) for more information. + /// + /// Default: `false` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.service.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.service.enabled`. +//documentation +//> Enables the external shuffle service. +//> +//> This service preserves the shuffle files written by executors e.g. so that executors can be safely removed, or so that shuffle fetches can continue in the event of executor failure. +//> The external shuffle service must be set up in order to enable it. See [dynamic allocation configuration and setup documentation](https://spark.apache.org/docs/latest/job-scheduling.html#configuration-and-setup) for more information. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Port on which the external shuffle service will run. + /// + /// Default: `7337` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.service.port`: UInt16? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.service.port`. +//documentation +//> Port on which the external shuffle service will run. +//> +//> Default: `7337` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt16# + + /// Cache entries limited to the specified memory footprint, in bytes unless otherwise specified. + /// + /// Default: `100.mib` + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.service.index.cache.size`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.service.index.cache.size`. +//documentation +//> Cache entries limited to the specified memory footprint, in bytes unless otherwise specified. +//> +//> Default: `100.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Whether to use the ExternalShuffleService for deleting shuffle blocks for deallocated executors when the shuffle is no longer needed. + /// + /// Without this enabled, shuffle data on executors that are deallocated will remain on disk until the application ends. + /// + /// Default: `false` + @Since { version = "3.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.service.removeShuffle`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.service.removeShuffle`. +//documentation +//> Whether to use the ExternalShuffleService for deleting shuffle blocks for deallocated executors when the shuffle is no longer needed. +//> +//> Without this enabled, shuffle data on executors that are deallocated will remain on disk until the application ends. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The max number of chunks allowed to be transferred at the same time on shuffle service. + /// + /// Note that new incoming connections will be closed when the max number is hit. + /// The client will retry according to the shuffle retry configs (see `spark.shuffle.io.maxRetries` and `spark.shuffle.io.retryWait`), if those limits are reached the task will fail with fetch failure. + /// + /// Default: `"Long.MAX_VALUE"` + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.maxChunksBeingTransferred`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.maxChunksBeingTransferred`. +//documentation +//> The max number of chunks allowed to be transferred at the same time on shuffle service. +//> +//> Note that new incoming connections will be closed when the max number is hit. +//> The client will retry according to the shuffle retry configs (see `spark.shuffle.io.maxRetries` and `spark.shuffle.io.retryWait`), if those limits are reached the task will fail with fetch failure. +//> +//> Default: `"Long.MAX_VALUE"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// (Advanced) In the sort-based shuffle manager, avoid merge-sorting data if there is no map-side aggregation and there are at most this many reduce partitions. + /// + /// Default: `200` + @Since { version = "1.1.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.sort.bypassMergeThreshold`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.sort.bypassMergeThreshold`. +//documentation +//> (Advanced) In the sort-based shuffle manager, avoid merge-sorting data if there is no map-side aggregation and there are at most this many reduce partitions. +//> +//> Default: `200` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Whether to compress data spilled during shuffles. + /// + /// Compression will use `spark.io.compression.codec`. + /// + /// Default: `true` + @Since { version = "0.9.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.spill.compress`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.spill.compress`. +//documentation +//> Whether to compress data spilled during shuffles. +//> +//> Compression will use `spark.io.compression.codec`. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Threshold in bytes above which the size of shuffle blocks in HighlyCompressedMapStatus is accurately recorded. + /// + /// This helps to prevent OOM by avoiding underestimating shuffle block size when fetch shuffle blocks. + /// + /// Default: `100 * 1024 * 1024` + @Since { version = "2.2.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.accurateBlockThreshold`: Number? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.accurateBlockThreshold`. +//documentation +//> Threshold in bytes above which the size of shuffle blocks in HighlyCompressedMapStatus is accurately recorded. +//> +//> This helps to prevent OOM by avoiding underestimating shuffle block size when fetch shuffle blocks. +//> +//> Default: `100 * 1024 * 1024` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// Timeout in milliseconds for registration to the external shuffle service. + /// + /// Default: `5000` + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.registration.timeout`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.registration.timeout`. +//documentation +//> Timeout in milliseconds for registration to the external shuffle service. +//> +//> Default: `5000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// When we fail to register to the external shuffle service, we will retry for maxAttempts times. + /// + /// Default: `3` + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.registration.maxAttempts`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.registration.maxAttempts`. +//documentation +//> When we fail to register to the external shuffle service, we will retry for maxAttempts times. +//> +//> Default: `3` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Timeout for the established connections for fetching files in Spark RPC environments to be marked as idled and closed if there are still outstanding files being downloaded but no traffic no the channel for at least \`connectionTimeout\`. + /// + /// Default: value of spark.network.timeout + @Since { version = "1.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.files.io.connectionTimeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.files.io.connectionTimeout`. +//documentation +//> Timeout for the established connections for fetching files in Spark RPC environments to be marked as idled and closed if there are still outstanding files being downloaded but no traffic no the channel for at least \`connectionTimeout\`. +//> +//> Default: value of spark.network.timeout +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Whether to calculate the checksum of shuffle data. + /// + /// If enabled, Spark will calculate the checksum values for each partition data within the map output file and store the values in a checksum file on the disk. + /// When there's shuffle data corruption detected, Spark will try to diagnose the cause (e.g., network issue, disk issue, etc.) of the corruption by using the checksum file. + /// + /// Default: `true` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.checksum.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.checksum.enabled`. +//documentation +//> Whether to calculate the checksum of shuffle data. +//> +//> If enabled, Spark will calculate the checksum values for each partition data within the map output file and store the values in a checksum file on the disk. +//> When there's shuffle data corruption detected, Spark will try to diagnose the cause (e.g., network issue, disk issue, etc.) of the corruption by using the checksum file. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The algorithm is used to calculate the shuffle checksum. + /// + /// Currently, it only supports built-in algorithms of JDK, e.g., ADLER32, CRC32. + /// + /// Default: `"ADLER32"` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.checksum.algorithm`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.checksum.algorithm`. +//documentation +//> The algorithm is used to calculate the shuffle checksum. +//> +//> Currently, it only supports built-in algorithms of JDK, e.g., ADLER32, CRC32. +//> +//> Default: `"ADLER32"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Whether to use the ExternalShuffleService for fetching disk persisted RDD blocks. + /// + /// In case of dynamic allocation if this feature is enabled executors having only disk persisted blocks are considered idle after `spark.dynamicAllocation.executorIdleTimeout` and will be released accordingly. + /// + /// Default: `false` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.service.fetch.rdd.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.service.fetch.rdd.enabled`. +//documentation +//> Whether to use the ExternalShuffleService for fetching disk persisted RDD blocks. +//> +//> In case of dynamic allocation if this feature is enabled executors having only disk persisted blocks are considered idle after `spark.dynamicAllocation.executorIdleTimeout` and will be released accordingly. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Whether to log events for every block update, if `spark.eventLog.enabled` is true. + /// + /// \*Warning\*: This will increase the size of the event log considerably. + /// + /// Default: `false` + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.logBlockUpdates.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.logBlockUpdates.enabled`. +//documentation +//> Whether to log events for every block update, if `spark.eventLog.enabled` is true. +//> +//> \*Warning\*: This will increase the size of the event log considerably. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// If true, use the long form of call sites in the event log. + /// + /// Otherwise use the short form. + /// + /// Default: `false` + @Since { version = "2.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.longForm.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.longForm.enabled`. +//documentation +//> If true, use the long form of call sites in the event log. +//> +//> Otherwise use the short form. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Whether to compress logged events, if `spark.eventLog.enabled` is true. + /// + /// Default: `false` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.compress`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.compress`. +//documentation +//> Whether to compress logged events, if `spark.eventLog.enabled` is true. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The codec to compress logged events. + /// + /// By default, Spark provides four codecs: `lz4`, `lzf`, `snappy`, and `zstd`. + /// You can also use fully qualified class names to specify the codec, e.g. `org.apache.spark.io.LZ4CompressionCodec`, + /// `org.apache.spark.io.LZFCompressionCodec`, + /// `org.apache.spark.io.SnappyCompressionCodec`, + /// and `org.apache.spark.io.ZStdCompressionCodec`. + /// + /// Default: `"zstd"` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.compression.codec`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.compression.codec`. +//documentation +//> The codec to compress logged events. +//> +//> By default, Spark provides four codecs: `lz4`, `lzf`, `snappy`, and `zstd`. +//> You can also use fully qualified class names to specify the codec, e.g. `org.apache.spark.io.LZ4CompressionCodec`, +//> `org.apache.spark.io.LZFCompressionCodec`, +//> `org.apache.spark.io.SnappyCompressionCodec`, +//> and `org.apache.spark.io.ZStdCompressionCodec`. +//> +//> Default: `"zstd"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Whether to allow event logs to use erasure coding, or turn erasure coding off, regardless of filesystem defaults. + /// + /// On HDFS, erasure coded files will not update as quickly as regular replicated files, so the application updates will take longer to appear in the History Server. + /// Note that even if this is true, Spark will still not force the file to use erasure coding, it will simply use filesystem defaults. + /// + /// Default: `false` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.erasureCoding.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.erasureCoding.enabled`. +//documentation +//> Whether to allow event logs to use erasure coding, or turn erasure coding off, regardless of filesystem defaults. +//> +//> On HDFS, erasure coded files will not update as quickly as regular replicated files, so the application updates will take longer to appear in the History Server. +//> Note that even if this is true, Spark will still not force the file to use erasure coding, it will simply use filesystem defaults. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Base directory in which Spark events are logged, if `spark.eventLog.enabled` is true. + /// + /// Within this base directory, Spark creates a sub-directory for each application, and logs the events specific to the application in this directory. + /// Users may want to set this to a unified location like an HDFS directory so history files can be read by the history server. + /// + /// Default: `"file:///tmp/spark-events"` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.dir`: String? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.dir`. +//documentation +//> Base directory in which Spark events are logged, if `spark.eventLog.enabled` is true. +//> +//> Within this base directory, Spark creates a sub-directory for each application, and logs the events specific to the application in this directory. +//> Users may want to set this to a unified location like an HDFS directory so history files can be read by the history server. +//> +//> Default: `"file:///tmp/spark-events"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Whether to log Spark events, useful for reconstructing the Web UI after the application has finished. + /// + /// Default: `false` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.enabled`. +//documentation +//> Whether to log Spark events, useful for reconstructing the Web UI after the application has finished. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Whether to overwrite any existing files. + /// + /// Default: `false` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.overwrite`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.overwrite`. +//documentation +//> Whether to overwrite any existing files. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Buffer size to use when writing to output streams, in KiB unless otherwise specified. + /// + /// Default: `100.kib` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.buffer.kb`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.buffer.kb`. +//documentation +//> Buffer size to use when writing to output streams, in KiB unless otherwise specified. +//> +//> Default: `100.kib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Whether rolling over event log files is enabled. + /// + /// If set to true, it cuts down each event log file to the configured size. + /// + /// Default: `false` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.rolling.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.rolling.enabled`. +//documentation +//> Whether rolling over event log files is enabled. +//> +//> If set to true, it cuts down each event log file to the configured size. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// When `spark.eventLog.rolling.enabled=true`, specifies the max size of event log file before it's rolled over. + /// + /// Default: `128.mib` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.rolling.maxFileSize`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.rolling.maxFileSize`. +//documentation +//> When `spark.eventLog.rolling.enabled=true`, specifies the max size of event log file before it's rolled over. +//> +//> Default: `128.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// How many DAG graph nodes the Spark UI and status APIs remember before garbage collecting. + /// + /// Default: `2147483647` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.dagGraph.retainedRootRDDs`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.dagGraph.retainedRootRDDs`. +//documentation +//> How many DAG graph nodes the Spark UI and status APIs remember before garbage collecting. +//> +//> Default: `2147483647` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Whether to run the web UI for the Spark application. + /// + /// Default: `true` + @Since { version = "1.1.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.enabled`. +//documentation +//> Whether to run the web UI for the Spark application. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Allows jobs and stages to be killed from the web UI. + /// + /// Default: `true` + @Reserved +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/Reserved# + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.killEnabled`: Null? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.killEnabled`. +//documentation +//> Allows jobs and stages to be killed from the web UI. +//> +//> Default: `true` +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# + + /// How often to update live entities. + /// + /// -1 means "never update" when replaying applications, meaning only the last write will happen. + /// For live applications, this avoids a few operations that we can live without when rapidly processing incoming task events. + /// + /// Default: `100.ms` + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.liveUpdate.period`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.liveUpdate.period`. +//documentation +//> How often to update live entities. +//> +//> -1 means "never update" when replaying applications, meaning only the last write will happen. +//> For live applications, this avoids a few operations that we can live without when rapidly processing incoming task events. +//> +//> Default: `100.ms` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Minimum time elapsed before stale UI data is flushed. + /// + /// This avoids UI staleness when incoming task events are not fired frequently. + /// + /// Default: `1.s` + @Since { version = "2.4.2" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.liveUpdate.minFlushPeriod`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.liveUpdate.minFlushPeriod`. +//documentation +//> Minimum time elapsed before stale UI data is flushed. +//> +//> This avoids UI staleness when incoming task events are not fired frequently. +//> +//> Default: `1.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Port for your application's dashboard, which shows memory and workload data. + /// + /// Default: `4040` + @Since { version = "0.7.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.port`: UInt16? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.port`. +//documentation +//> Port for your application's dashboard, which shows memory and workload data. +//> +//> Default: `4040` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt16# + + /// How many jobs the Spark UI and status APIs remember before garbage collecting. + /// + /// This is a target maximum, and fewer elements may be retained in some circumstances. + /// + /// Default: `1000` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.retainedJobs`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.retainedJobs`. +//documentation +//> How many jobs the Spark UI and status APIs remember before garbage collecting. +//> +//> This is a target maximum, and fewer elements may be retained in some circumstances. +//> +//> Default: `1000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// How many stages the Spark UI and status APIs remember before garbage collecting. + /// + /// This is a target maximum, and fewer elements may be retained in some circumstances. + /// + /// Default: `1000` + @Since { version = "0.9.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.retainedStages`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.retainedStages`. +//documentation +//> How many stages the Spark UI and status APIs remember before garbage collecting. +//> +//> This is a target maximum, and fewer elements may be retained in some circumstances. +//> +//> Default: `1000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// How many tasks in one stage the Spark UI and status APIs remember before garbage collecting. + /// + /// This is a target maximum, and fewer elements may be retained in some circumstances. + /// + /// Default: `100000` + @Since { version = "2.0.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.retainedTasks`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.retainedTasks`. +//documentation +//> How many tasks in one stage the Spark UI and status APIs remember before garbage collecting. +//> +//> This is a target maximum, and fewer elements may be retained in some circumstances. +//> +//> Default: `100000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Enable running Spark Master as reverse proxy for worker and application UIs. + /// + /// In this mode, Spark master will reverse proxy the worker and application UIs to enable access without requiring direct access to their hosts. + /// Use it with caution, as worker and application UI will not be accessible directly, you will only be able to access them through spark master/proxy public URL. + /// This setting affects all the workers and application UIs running in the cluster and must be set on all the workers, drivers and masters. + /// + /// Default: `false` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.reverseProxy`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.reverseProxy`. +//documentation +//> Enable running Spark Master as reverse proxy for worker and application UIs. +//> +//> In this mode, Spark master will reverse proxy the worker and application UIs to enable access without requiring direct access to their hosts. +//> Use it with caution, as worker and application UI will not be accessible directly, you will only be able to access them through spark master/proxy public URL. +//> This setting affects all the workers and application UIs running in the cluster and must be set on all the workers, drivers and masters. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// If the Spark UI should be served through another front-end reverse proxy, this is the URL for accessing the Spark master UI through that reverse proxy. + /// + /// This is useful when running proxy for authentication e.g. an OAuth proxy. + /// The URL may contain a path prefix, like `http://mydomain.com/path/to/spark/`, allowing you to serve the UI for multiple Spark clusters and other web applications through the same virtual host and port. + /// Normally, this should be an absolute URL including scheme (http/https), host and port. + /// It is possible to specify a relative URL starting with "/" here. + /// In this case, all URLs generated by the Spark UI and Spark REST APIs will be server-relative links -- this will still work, as the entire Spark UI is served through the same host and port. + /// The setting affects link generation in the Spark UI, but the front-end reverse proxy is responsible for + /// + /// * stripping a path prefix before forwarding the request, + /// * rewriting redirects which point directly to the Spark master, + /// * redirecting access from `http://mydomain.com/path/to/spark` to `http://mydomain.com/path/to/spark/` (trailing slash after path prefix); otherwise relative links on the master page do not work correctly. + /// + /// + /// This setting affects all the workers and application UIs running in the cluster and must be set identically on all the workers, drivers and masters. + /// In is only effective when `spark.ui.reverseProxy` is turned on. This setting is not needed when the Spark master web UI is directly reachable. + /// + /// Default: `null` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.reverseProxyUrl`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.reverseProxyUrl`. +//documentation +//> If the Spark UI should be served through another front-end reverse proxy, this is the URL for accessing the Spark master UI through that reverse proxy. +//> +//> This is useful when running proxy for authentication e.g. an OAuth proxy. +//> The URL may contain a path prefix, like `http://mydomain.com/path/to/spark/`, allowing you to serve the UI for multiple Spark clusters and other web applications through the same virtual host and port. +//> Normally, this should be an absolute URL including scheme (http/https), host and port. +//> It is possible to specify a relative URL starting with "/" here. +//> In this case, all URLs generated by the Spark UI and Spark REST APIs will be server-relative links -- this will still work, as the entire Spark UI is served through the same host and port. +//> The setting affects link generation in the Spark UI, but the front-end reverse proxy is responsible for +//> +//> * stripping a path prefix before forwarding the request, +//> * rewriting redirects which point directly to the Spark master, +//> * redirecting access from `http://mydomain.com/path/to/spark` to `http://mydomain.com/path/to/spark/` (trailing slash after path prefix); otherwise relative links on the master page do not work correctly. +//> +//> +//> This setting affects all the workers and application UIs running in the cluster and must be set identically on all the workers, drivers and masters. +//> In is only effective when `spark.ui.reverseProxy` is turned on. This setting is not needed when the Spark master web UI is directly reachable. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Where to address redirects when Spark is running behind a proxy. + /// + /// This will make Spark modify redirect responses so they point to the proxy server, instead of the Spark UI's own address. + /// This should be only the address of the server, without any prefix paths for the application; the prefix should be set either by the proxy server itself (by adding the `X-Forwarded-Context` request header), or by setting the proxy base in the Spark app's configuration. + /// + /// Default: `null` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.proxyRedirectUri`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.proxyRedirectUri`. +//documentation +//> Where to address redirects when Spark is running behind a proxy. +//> +//> This will make Spark modify redirect responses so they point to the proxy server, instead of the Spark UI's own address. +//> This should be only the address of the server, without any prefix paths for the application; the prefix should be set either by the proxy server itself (by adding the `X-Forwarded-Context` request header), or by setting the proxy base in the Spark app's configuration. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Show the progress bar in the console. + /// + /// The progress bar shows the progress of stages that run for longer than 500ms. + /// If multiple stages run at the same time, multiple progress bars will be displayed on the same line. + /// *Note:* In shell environment, the default value of spark.ui.showConsoleProgress is true. + /// + /// Default: `false` + @Since { version = "1.2.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.showConsoleProgress`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.showConsoleProgress`. +//documentation +//> Show the progress bar in the console. +//> +//> The progress bar shows the progress of stages that run for longer than 500ms. +//> If multiple stages run at the same time, multiple progress bars will be displayed on the same line. +//> *Note:* In shell environment, the default value of spark.ui.showConsoleProgress is true. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Specifies custom spark executor log URL for supporting external log service instead of using cluster managers' application log URLs in Spark UI. + /// + /// Spark will support some path variables via patterns which can vary on cluster manager. + /// Please check the documentation for your cluster manager to see which patterns are supported, if any. + /// + /// + ///
+ /// + /// Please note that this configuration also replaces original log urls in event log, which will be also effective when accessing the application on history server. + /// The new log urls must be permanent, otherwise you might have dead link for executor log urls. + /// + /// + ///
+ /// + /// For now, only YARN mode supports this configuration + /// + /// Default: `null` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.custom.executor.log.url`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.custom.executor.log.url`. +//documentation +//> Specifies custom spark executor log URL for supporting external log service instead of using cluster managers' application log URLs in Spark UI. +//> +//> Spark will support some path variables via patterns which can vary on cluster manager. +//> Please check the documentation for your cluster manager to see which patterns are supported, if any. +//> +//> +//>
+//> +//> Please note that this configuration also replaces original log urls in event log, which will be also effective when accessing the application on history server. +//> The new log urls must be permanent, otherwise you might have dead link for executor log urls. +//> +//> +//>
+//> +//> For now, only YARN mode supports this configuration +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// How many finished executors the Spark UI and status APIs remember before garbage collecting. + /// + /// Default: `1000` + @Since { version = "1.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.worker.ui.retainedExecutors`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.worker.ui.retainedExecutors`. +//documentation +//> How many finished executors the Spark UI and status APIs remember before garbage collecting. +//> +//> Default: `1000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// How many finished drivers the Spark UI and status APIs remember before garbage collecting. + /// + /// Default: `1000` + @Since { version = "1.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.worker.ui.retainedDrivers`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.worker.ui.retainedDrivers`. +//documentation +//> How many finished drivers the Spark UI and status APIs remember before garbage collecting. +//> +//> Default: `1000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// How many finished executions the Spark UI and status APIs remember before garbage collecting. + /// + /// Default: `1000` + @Since { version = "1.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.sql.ui.retainedExecutions`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.sql.ui.retainedExecutions`. +//documentation +//> How many finished executions the Spark UI and status APIs remember before garbage collecting. +//> +//> Default: `1000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// How many finished batches the Spark UI and status APIs remember before garbage collecting. + /// + /// Default: `1000` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.ui.retainedBatches`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.ui.retainedBatches`. +//documentation +//> How many finished batches the Spark UI and status APIs remember before garbage collecting. +//> +//> Default: `1000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// How many dead executors the Spark UI and status APIs remember before garbage collecting. + /// + /// Default: `100` + @Since { version = "2.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.retainedDeadExecutors`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.retainedDeadExecutors`. +//documentation +//> How many dead executors the Spark UI and status APIs remember before garbage collecting. +//> +//> Default: `100` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Comma separated list of filter class names to apply to the Spark Web UI. + /// + /// The filter should be a standard [javax servlet Filter](http://docs.oracle.com/javaee/6/api/javax/servlet/Filter.html). + /// + ///
Filter parameters can also be specified in the configuration, by setting config entries + /// of the form spark.<class name of filter>.param.<param name>=<value> + /// + ///
For example: + ///
spark.ui.filters=com.test.filter1 + ///
spark.com.test.filter1.param.name1=foo + ///
spark.com.test.filter1.param.name2=bar + /// + /// Default: `null` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.filters`: String? +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.filters`. +//documentation +//> Comma separated list of filter class names to apply to the Spark Web UI. +//> +//> The filter should be a standard [javax servlet Filter](http://docs.oracle.com/javaee/6/api/javax/servlet/Filter.html). +//> +//>
Filter parameters can also be specified in the configuration, by setting config entries +//> of the form spark.<class name of filter>.param.<param name>=<value> +//> +//>
For example: +//>
spark.ui.filters=com.test.filter1 +//>
spark.com.test.filter1.param.name1=foo +//>
spark.com.test.filter1.param.name2=bar +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The maximum allowed size for a HTTP request header, in bytes unless otherwise specified. + /// + /// This setting applies for the Spark History Server too. + /// + /// Default: `8.kib` + @Since { version = "2.2.3" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.requestHeaderSize`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.requestHeaderSize`. +//documentation +//> The maximum allowed size for a HTTP request header, in bytes unless otherwise specified. +//> +//> This setting applies for the Spark History Server too. +//> +//> Default: `8.kib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// The maximum number of executors shown in the event timeline. + /// + /// Default: `250` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.timeline.executors.maximum`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.timeline.executors.maximum`. +//documentation +//> The maximum number of executors shown in the event timeline. +//> +//> Default: `250` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// The maximum number of jobs shown in the event timeline. + /// + /// Default: `500` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.timeline.jobs.maximum`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.timeline.jobs.maximum`. +//documentation +//> The maximum number of jobs shown in the event timeline. +//> +//> Default: `500` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// The maximum number of stages shown in the event timeline. + /// + /// Default: `500` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.timeline.stages.maximum`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.timeline.stages.maximum`. +//documentation +//> The maximum number of stages shown in the event timeline. +//> +//> Default: `500` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// The maximum number of tasks shown in the event timeline. + /// + /// Default: `1000` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.ui.timeline.tasks.maximum`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.ui.timeline.tasks.maximum`. +//documentation +//> The maximum number of tasks shown in the event timeline. +//> +//> Default: `1000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Whether to compress broadcast variables before sending them. + /// + /// Generally a good idea. + /// Compression will use `spark.io.compression.codec`. + /// + /// Default: `true` + @Since { version = "0.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.broadcast.compress`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.broadcast.compress`. +//documentation +//> Whether to compress broadcast variables before sending them. +//> +//> Generally a good idea. +//> Compression will use `spark.io.compression.codec`. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Whether to compress RDD checkpoints. + /// + /// Generally a good idea. + /// Compression will use `spark.io.compression.codec`. + /// + /// Default: `false` + @Since { version = "2.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.checkpoint.compress`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.checkpoint.compress`. +//documentation +//> Whether to compress RDD checkpoints. +//> +//> Generally a good idea. +//> Compression will use `spark.io.compression.codec`. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The codec used to compress internal data such as RDD partitions, event log, broadcast variables and shuffle outputs. + /// + /// By default, Spark provides four codecs: `lz4`, `lzf`, `snappy`, and `zstd`. + /// You can also use fully qualified class names to specify the codec, e.g. `org.apache.spark.io.LZ4CompressionCodec`, `org.apache.spark.io.LZFCompressionCodec`, `org.apache.spark.io.SnappyCompressionCodec`, and `org.apache.spark.io.ZStdCompressionCodec`. + /// + /// Default: `"lz4"` + @Since { version = "0.8.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.io.compression.codec`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.io.compression.codec`. +//documentation +//> The codec used to compress internal data such as RDD partitions, event log, broadcast variables and shuffle outputs. +//> +//> By default, Spark provides four codecs: `lz4`, `lzf`, `snappy`, and `zstd`. +//> You can also use fully qualified class names to specify the codec, e.g. `org.apache.spark.io.LZ4CompressionCodec`, `org.apache.spark.io.LZFCompressionCodec`, `org.apache.spark.io.SnappyCompressionCodec`, and `org.apache.spark.io.ZStdCompressionCodec`. +//> +//> Default: `"lz4"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Block size used in LZ4 compression, in the case when LZ4 compression codec is used. + /// + /// Lowering this block size will also lower shuffle memory usage when LZ4 is used. + /// Default unit is bytes, unless otherwise specified. + /// + /// Default: `32.kib` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.io.compression.lz4.blockSize`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.io.compression.lz4.blockSize`. +//documentation +//> Block size used in LZ4 compression, in the case when LZ4 compression codec is used. +//> +//> Lowering this block size will also lower shuffle memory usage when LZ4 is used. +//> Default unit is bytes, unless otherwise specified. +//> +//> Default: `32.kib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Block size in Snappy compression, in the case when Snappy compression codec is used. + /// + /// Lowering this block size will also lower shuffle memory usage when Snappy is used. + /// Default unit is bytes, unless otherwise specified. + /// + /// Default: `32.kib` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.io.compression.snappy.blockSize`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.io.compression.snappy.blockSize`. +//documentation +//> Block size in Snappy compression, in the case when Snappy compression codec is used. +//> +//> Lowering this block size will also lower shuffle memory usage when Snappy is used. +//> Default unit is bytes, unless otherwise specified. +//> +//> Default: `32.kib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Compression level for Zstd compression codec. + /// + /// Increasing the compression level will result in better compression at the expense of more CPU and memory. + /// + /// Default: `1` + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.io.compression.zstd.level`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.io.compression.zstd.level`. +//documentation +//> Compression level for Zstd compression codec. +//> +//> Increasing the compression level will result in better compression at the expense of more CPU and memory. +//> +//> Default: `1` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Buffer size in bytes used in Zstd compression, in the case when Zstd compression codec is used. + /// + /// Lowering this size will lower the shuffle memory usage when Zstd is used, but it might increase the compression cost because of excessive JNI call overhead. + /// + /// Default: `32.kib` + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.io.compression.zstd.bufferSize`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.io.compression.zstd.bufferSize`. +//documentation +//> Buffer size in bytes used in Zstd compression, in the case when Zstd compression codec is used. +//> +//> Lowering this size will lower the shuffle memory usage when Zstd is used, but it might increase the compression cost because of excessive JNI call overhead. +//> +//> Default: `32.kib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// If you use Kryo serialization, give a comma-separated list of custom class names to register with Kryo. + /// + /// See the [tuning guide](https://spark.apache.org/docs/latest/tuning.html#data-serialization) for more details. + /// + /// Default: `null` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.kryo.classesToRegister`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.kryo.classesToRegister`. +//documentation +//> If you use Kryo serialization, give a comma-separated list of custom class names to register with Kryo. +//> +//> See the [tuning guide](https://spark.apache.org/docs/latest/tuning.html#data-serialization) for more details. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Whether to track references to the same object when serializing data with Kryo, which is necessary if your object graphs have loops and useful for efficiency if they contain multiple copies of the same object. + /// + /// Can be disabled to improve performance if you know this is not the case. + /// + /// Default: `true` + @Since { version = "0.8.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.kryo.referenceTracking`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.kryo.referenceTracking`. +//documentation +//> Whether to track references to the same object when serializing data with Kryo, which is necessary if your object graphs have loops and useful for efficiency if they contain multiple copies of the same object. +//> +//> Can be disabled to improve performance if you know this is not the case. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Whether to require registration with Kryo. + /// + /// If set to 'true', Kryo will throw an exception if an unregistered class is serialized. + /// If set to false (the default), Kryo will write unregistered class names along with each object. + /// Writing class names can cause significant performance overhead, so enabling this option can enforce strictly that a user has not omitted classes from registration. + /// + /// Default: `false` + @Since { version = "1.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.kryo.registrationRequired`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.kryo.registrationRequired`. +//documentation +//> Whether to require registration with Kryo. +//> +//> If set to 'true', Kryo will throw an exception if an unregistered class is serialized. +//> If set to false (the default), Kryo will write unregistered class names along with each object. +//> Writing class names can cause significant performance overhead, so enabling this option can enforce strictly that a user has not omitted classes from registration. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// If you use Kryo serialization, give a comma-separated list of classes that register your custom classes with Kryo. + /// + /// This property is useful if you need to register your classes in a custom way, e.g. to specify a custom field serializer. + /// Otherwise `spark.kryo.classesToRegister` is simpler. + /// It should be set to classes that extend [`KryoRegistrator`](https://spark.apache.org/docs/latest/api/scala/org/apache/spark/serializer/KryoRegistrator.html). + /// See the [tuning guide](https://spark.apache.org/docs/latest/tuning.html#data-serialization) for more details. + /// + /// Default: `null` + @Since { version = "0.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.kryo.registrator`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.kryo.registrator`. +//documentation +//> If you use Kryo serialization, give a comma-separated list of classes that register your custom classes with Kryo. +//> +//> This property is useful if you need to register your classes in a custom way, e.g. to specify a custom field serializer. +//> Otherwise `spark.kryo.classesToRegister` is simpler. +//> It should be set to classes that extend [`KryoRegistrator`](https://spark.apache.org/docs/latest/api/scala/org/apache/spark/serializer/KryoRegistrator.html). +//> See the [tuning guide](https://spark.apache.org/docs/latest/tuning.html#data-serialization) for more details. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Whether to use unsafe based Kryo serializer. + /// + /// Can be substantially faster by using Unsafe Based IO. + /// + /// Default: `false` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.kryo.unsafe`: Boolean? +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.kryo.unsafe`. +//documentation +//> Whether to use unsafe based Kryo serializer. +//> +//> Can be substantially faster by using Unsafe Based IO. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Maximum allowable size of Kryo serialization buffer, in MiB unless otherwise specified. + /// + /// This must be larger than any object you attempt to serialize and must be less than 2048m. + /// Increase this if you get a "buffer limit exceeded" exception inside Kryo. + /// + /// Default: `64.mib` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.kryoserializer.buffer.max`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.kryoserializer.buffer.max`. +//documentation +//> Maximum allowable size of Kryo serialization buffer, in MiB unless otherwise specified. +//> +//> This must be larger than any object you attempt to serialize and must be less than 2048m. +//> Increase this if you get a "buffer limit exceeded" exception inside Kryo. +//> +//> Default: `64.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Initial size of Kryo's serialization buffer, in KiB unless otherwise specified. + /// + /// Note that there will be one buffer *per core* on each worker. + /// This buffer will grow up to `spark.kryoserializer.buffer.max` if needed. + /// + /// Default: `64.kib` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.kryoserializer.buffer`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.kryoserializer.buffer`. +//documentation +//> Initial size of Kryo's serialization buffer, in KiB unless otherwise specified. +//> +//> Note that there will be one buffer *per core* on each worker. +//> This buffer will grow up to `spark.kryoserializer.buffer.max` if needed. +//> +//> Default: `64.kib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Whether to compress serialized RDD partitions (e.g. + /// + /// for `StorageLevel.MEMORY_ONLY_SER` in Java and Scala or `StorageLevel.MEMORY_ONLY` in Python). + /// Can save substantial space at the cost of some extra CPU time. + /// Compression will use `spark.io.compression.codec`. + /// + /// Default: `false` + @Since { version = "0.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.rdd.compress`: Boolean? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.rdd.compress`. +//documentation +//> Whether to compress serialized RDD partitions (e.g. +//> +//> for `StorageLevel.MEMORY_ONLY_SER` in Java and Scala or `StorageLevel.MEMORY_ONLY` in Python). +//> Can save substantial space at the cost of some extra CPU time. +//> Compression will use `spark.io.compression.codec`. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Class to use for serializing objects that will be sent over the network or need to be cached in serialized form. + /// + /// The default of Java serialization works with any Serializable Java object but is quite slow, so we recommend [using `org.apache.spark.serializer.KryoSerializer` and configuring Kryo serialization](https://spark.apache.org/docs/latest/tuning.html) when speed is necessary. + /// Can be any subclass of [`org.apache.spark.Serializer`](https://spark.apache.org/docs/latest/api/scala/org/apache/spark/serializer/Serializer.html). + /// + /// Default: org.apache.spark.serializer. JavaSerializer + @Since { version = "0.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.serializer`: String? +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.serializer`. +//documentation +//> Class to use for serializing objects that will be sent over the network or need to be cached in serialized form. +//> +//> The default of Java serialization works with any Serializable Java object but is quite slow, so we recommend [using `org.apache.spark.serializer.KryoSerializer` and configuring Kryo serialization](https://spark.apache.org/docs/latest/tuning.html) when speed is necessary. +//> Can be any subclass of [`org.apache.spark.Serializer`](https://spark.apache.org/docs/latest/api/scala/org/apache/spark/serializer/Serializer.html). +//> +//> Default: org.apache.spark.serializer. JavaSerializer +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// When serializing using org.apache.spark.serializer.JavaSerializer, the serializer caches objects to prevent writing redundant data, however that stops garbage collection of those objects. + /// + /// By calling 'reset' you flush that info from the serializer, and allow old objects to be collected. + /// To turn off this periodic reset set it to -1. By default it will reset the serializer every 100 objects. + /// + /// Default: `100` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.serializer.objectStreamReset`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.serializer.objectStreamReset`. +//documentation +//> When serializing using org.apache.spark.serializer.JavaSerializer, the serializer caches objects to prevent writing redundant data, however that stops garbage collection of those objects. +//> +//> By calling 'reset' you flush that info from the serializer, and allow old objects to be collected. +//> To turn off this periodic reset set it to -1. By default it will reset the serializer every 100 objects. +//> +//> Default: `100` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Fraction of (heap space - 300MB) used for execution and storage. + /// + /// The lower this is, the more frequently spills and cached data eviction occur. + /// The purpose of this config is to set aside memory for internal metadata, user data structures, and imprecise size estimation in the case of sparse, unusually large records. + /// Leaving this at the default value is recommended. + /// For more detail, including important information about correctly tuning JVM garbage collection when increasing this value, see [this description](https://spark.apache.org/docs/latest/tuning.html#memory-management-overview). + /// + /// Default: `0.6` + @Since { version = "1.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.memory.fraction`: Float? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.memory.fraction`. +//documentation +//> Fraction of (heap space - 300MB) used for execution and storage. +//> +//> The lower this is, the more frequently spills and cached data eviction occur. +//> The purpose of this config is to set aside memory for internal metadata, user data structures, and imprecise size estimation in the case of sparse, unusually large records. +//> Leaving this at the default value is recommended. +//> For more detail, including important information about correctly tuning JVM garbage collection when increasing this value, see [this description](https://spark.apache.org/docs/latest/tuning.html#memory-management-overview). +//> +//> Default: `0.6` +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + + /// Amount of storage memory immune to eviction, expressed as a fraction of the size of the region set aside by `spark.memory.fraction`. + /// + /// The higher this is, the less working memory may be available to execution and tasks may spill to disk more often. + /// Leaving this at the default value is recommended. + /// For more detail, see [this description](https://spark.apache.org/docs/latest/tuning.html#memory-management-overview). + /// + /// Default: `0.5` + @Since { version = "1.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.memory.storageFraction`: Float? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.memory.storageFraction`. +//documentation +//> Amount of storage memory immune to eviction, expressed as a fraction of the size of the region set aside by `spark.memory.fraction`. +//> +//> The higher this is, the less working memory may be available to execution and tasks may spill to disk more often. +//> Leaving this at the default value is recommended. +//> For more detail, see [this description](https://spark.apache.org/docs/latest/tuning.html#memory-management-overview). +//> +//> Default: `0.5` +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + + /// If true, Spark will attempt to use off-heap memory for certain operations. + /// + /// If off-heap memory use is enabled, then `spark.memory.offHeap.size` must be positive. + /// + /// Default: `false` + @Since { version = "1.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.memory.offHeap.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.memory.offHeap.enabled`. +//documentation +//> If true, Spark will attempt to use off-heap memory for certain operations. +//> +//> If off-heap memory use is enabled, then `spark.memory.offHeap.size` must be positive. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The absolute amount of memory which can be used for off-heap allocation, in bytes unless otherwise specified. + /// + /// This setting has no impact on heap memory usage, so if your executors' total memory consumption must fit within some hard limit then be sure to shrink your JVM heap size accordingly. + /// This must be set to a positive value when `spark.memory.offHeap.enabled=true`. + /// + /// Default: `0` + @Since { version = "1.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.memory.offHeap.size`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.memory.offHeap.size`. +//documentation +//> The absolute amount of memory which can be used for off-heap allocation, in bytes unless otherwise specified. +//> +//> This setting has no impact on heap memory usage, so if your executors' total memory consumption must fit within some hard limit then be sure to shrink your JVM heap size accordingly. +//> This must be set to a positive value when `spark.memory.offHeap.enabled=true`. +//> +//> Default: `0` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Enables proactive block replication for RDD blocks. + /// + /// Cached RDD block replicas lost due to executor failures are replenished if there are any existing available replicas. + /// This tries to get the replication level of the block to the initial number. + /// + /// Default: `false` + @Since { version = "2.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.storage.replication.proactive`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.storage.replication.proactive`. +//documentation +//> Enables proactive block replication for RDD blocks. +//> +//> Cached RDD block replicas lost due to executor failures are replenished if there are any existing available replicas. +//> This tries to get the replication level of the block to the initial number. +//> +//> Default: `false` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Controls how often to trigger a garbage collection. + /// + /// + /// This context cleaner triggers cleanups only when weak references are garbage collected. + /// In long-running applications with large driver JVMs, where there is little memory pressure on the driver, this may happen very occasionally or not at all. + /// Not cleaning at all may lead to executors running out of disk space after a while. + /// + /// Default: `30.min` + @Since { version = "1.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.cleaner.periodicGC.interval`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.cleaner.periodicGC.interval`. +//documentation +//> Controls how often to trigger a garbage collection. +//> +//> +//> This context cleaner triggers cleanups only when weak references are garbage collected. +//> In long-running applications with large driver JVMs, where there is little memory pressure on the driver, this may happen very occasionally or not at all. +//> Not cleaning at all may lead to executors running out of disk space after a while. +//> +//> Default: `30.min` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Enables or disables context cleaning. + /// + /// Default: `true` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.cleaner.referenceTracking`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.cleaner.referenceTracking`. +//documentation +//> Enables or disables context cleaning. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Controls whether the cleaning thread should block on cleanup tasks (other than shuffle, which is controlled by `spark.cleaner.referenceTracking.blocking.shuffle` Spark property). + /// + /// Default: `true` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.cleaner.referenceTracking.blocking`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.cleaner.referenceTracking.blocking`. +//documentation +//> Controls whether the cleaning thread should block on cleanup tasks (other than shuffle, which is controlled by `spark.cleaner.referenceTracking.blocking.shuffle` Spark property). +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Controls whether the cleaning thread should block on shuffle cleanup tasks. + /// + /// Default: `false` + @Since { version = "1.1.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.cleaner.referenceTracking.blocking.shuffle`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.cleaner.referenceTracking.blocking.shuffle`. +//documentation +//> Controls whether the cleaning thread should block on shuffle cleanup tasks. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Controls whether to clean checkpoint files if the reference is out of scope. + /// + /// Default: `false` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.cleaner.referenceTracking.cleanCheckpoints`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.cleaner.referenceTracking.cleanCheckpoints`. +//documentation +//> Controls whether to clean checkpoint files if the reference is out of scope. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Size of each piece of a block for `TorrentBroadcastFactory`, in KiB unless otherwise specified. + /// + /// Too large a value decreases parallelism during broadcast (makes it slower); however, if it is too small, `BlockManager` might take a performance hit. + /// + /// Default: `4.mib` + @Since { version = "0.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.broadcast.blockSize`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.broadcast.blockSize`. +//documentation +//> Size of each piece of a block for `TorrentBroadcastFactory`, in KiB unless otherwise specified. +//> +//> Too large a value decreases parallelism during broadcast (makes it slower); however, if it is too small, `BlockManager` might take a performance hit. +//> +//> Default: `4.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Whether to enable checksum for broadcast. + /// + /// If enabled, broadcasts will include a checksum, which can help detect corrupted blocks, at the cost of computing and sending a little more data. + /// It's possible to disable it if the network has other mechanisms to guarantee data won't be corrupted during broadcast. + /// + /// Default: `true` + @Since { version = "2.1.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.broadcast.checksum`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.broadcast.checksum`. +//documentation +//> Whether to enable checksum for broadcast. +//> +//> If enabled, broadcasts will include a checksum, which can help detect corrupted blocks, at the cost of computing and sending a little more data. +//> It's possible to disable it if the network has other mechanisms to guarantee data won't be corrupted during broadcast. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The number of cores to use on each executor. + /// + /// + /// In standalone and Mesos coarse-grained modes, for more detail, see + /// this description. + /// + /// Default: `1 in YARN mode, all the available cores on the worker in standalone and Mesos coarse-grained modes.` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.cores`: Number? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.cores`. +//documentation +//> The number of cores to use on each executor. +//> +//> +//> In standalone and Mesos coarse-grained modes, for more detail, see +//> this description. +//> +//> Default: `1 in YARN mode, all the available cores on the worker in standalone and Mesos coarse-grained modes.` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// Default number of partitions in RDDs returned by transformations like `join`, `reduceByKey`, and `parallelize` when not set by user. + /// + /// Default: For distributed shuffle operations like reduceByKey and join, the largest number of partitions in a parent RDD. For operations like parallelize with no parent RDDs, it depends on the cluster manager: Local mode: number of cores on the local machine Mesos fine grained mode: 8 Others: total number of cores on all executor nodes or 2, whichever is larger + @Since { version = "0.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.default.parallelism`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.default.parallelism`. +//documentation +//> Default number of partitions in RDDs returned by transformations like `join`, `reduceByKey`, and `parallelize` when not set by user. +//> +//> Default: For distributed shuffle operations like reduceByKey and join, the largest number of partitions in a parent RDD. For operations like parallelize with no parent RDDs, it depends on the cluster manager: Local mode: number of cores on the local machine Mesos fine grained mode: 8 Others: total number of cores on all executor nodes or 2, whichever is larger +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Interval between each executor's heartbeats to the driver. + /// + /// Heartbeats let the driver know that the executor is still alive and update it with metrics for in-progress tasks. + /// spark.executor.heartbeatInterval should be significantly less than spark.network.timeout + /// + /// Default: `10.s` + @Since { version = "1.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.heartbeatInterval`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.heartbeatInterval`. +//documentation +//> Interval between each executor's heartbeats to the driver. +//> +//> Heartbeats let the driver know that the executor is still alive and update it with metrics for in-progress tasks. +//> spark.executor.heartbeatInterval should be significantly less than spark.network.timeout +//> +//> Default: `10.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Communication timeout to use when fetching files added through SparkContext.addFile() from the driver. + /// + /// Default: `60.s` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.files.fetchTimeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.files.fetchTimeout`. +//documentation +//> Communication timeout to use when fetching files added through SparkContext.addFile() from the driver. +//> +//> Default: `60.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// If set to true (default), file fetching will use a local cache that is shared by executors that belong to the same application, which can improve task launching performance when running many executors on the same host. + /// + /// If set to false, these caching optimizations will be disabled and all executors will fetch their own copies of files. + /// This optimization may be disabled in order to use Spark local directories that reside on NFS filesystems (see [SPARK-6313](https://issues.apache.org/jira/browse/SPARK-6313) for more details). + /// + /// Default: `true` + @Since { version = "1.2.2" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.files.useFetchCache`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.files.useFetchCache`. +//documentation +//> If set to true (default), file fetching will use a local cache that is shared by executors that belong to the same application, which can improve task launching performance when running many executors on the same host. +//> +//> If set to false, these caching optimizations will be disabled and all executors will fetch their own copies of files. +//> This optimization may be disabled in order to use Spark local directories that reside on NFS filesystems (see [SPARK-6313](https://issues.apache.org/jira/browse/SPARK-6313) for more details). +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Whether to overwrite any files which exist at the startup. + /// + /// Users can not overwrite the files added by `SparkContext.addFile` or `SparkContext.addJar` before even if this option is set `true`. + /// + /// Default: `false` + @Since { version = "1.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.files.overwrite`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.files.overwrite`. +//documentation +//> Whether to overwrite any files which exist at the startup. +//> +//> Users can not overwrite the files added by `SparkContext.addFile` or `SparkContext.addJar` before even if this option is set `true`. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The maximum number of bytes to pack into a single partition when reading files. + /// + /// Default: `134217728 (128 MiB)` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.files.maxPartitionBytes`: Number? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.files.maxPartitionBytes`. +//documentation +//> The maximum number of bytes to pack into a single partition when reading files. +//> +//> Default: `134217728 (128 MiB)` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// The estimated cost to open a file, measured by the number of bytes could be scanned at the same time. + /// + /// This is used when putting multiple files into a partition. + /// It is better to overestimate, then the partitions with small files will be faster than partitions with bigger files. + /// + /// Default: `4194304 (4 MiB)` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.files.openCostInBytes`: Number? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.files.openCostInBytes`. +//documentation +//> The estimated cost to open a file, measured by the number of bytes could be scanned at the same time. +//> +//> This is used when putting multiple files into a partition. +//> It is better to overestimate, then the partitions with small files will be faster than partitions with bigger files. +//> +//> Default: `4194304 (4 MiB)` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// If set to true, clones a new Hadoop `Configuration` object for each task. + /// + /// This option should be enabled to work around `Configuration` thread-safety issues (see [SPARK-2546](https://issues.apache.org/jira/browse/SPARK-2546) for more details). + /// This is disabled by default in order to avoid unexpected performance regressions for jobs that are not affected by these issues. + /// + /// Default: `false` + @Since { version = "1.0.3" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.hadoop.cloneConf`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.hadoop.cloneConf`. +//documentation +//> If set to true, clones a new Hadoop `Configuration` object for each task. +//> +//> This option should be enabled to work around `Configuration` thread-safety issues (see [SPARK-2546](https://issues.apache.org/jira/browse/SPARK-2546) for more details). +//> This is disabled by default in order to avoid unexpected performance regressions for jobs that are not affected by these issues. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// If set to true, validates the output specification (e.g. + /// + /// checking if the output directory already exists) used in saveAsHadoopFile and other variants. + /// This can be disabled to silence exceptions due to pre-existing output directories. + /// We recommend that users do not disable this except if trying to achieve compatibility with previous versions of Spark. + /// Simply use Hadoop's FileSystem API to delete output directories by hand. + /// This setting is ignored for jobs generated through Spark Streaming's StreamingContext, since data may need to be rewritten to pre-existing output directories during checkpoint recovery. + /// + /// Default: `true` + @Since { version = "1.0.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.hadoop.validateOutputSpecs`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.hadoop.validateOutputSpecs`. +//documentation +//> If set to true, validates the output specification (e.g. +//> +//> checking if the output directory already exists) used in saveAsHadoopFile and other variants. +//> This can be disabled to silence exceptions due to pre-existing output directories. +//> We recommend that users do not disable this except if trying to achieve compatibility with previous versions of Spark. +//> Simply use Hadoop's FileSystem API to delete output directories by hand. +//> This setting is ignored for jobs generated through Spark Streaming's StreamingContext, since data may need to be rewritten to pre-existing output directories during checkpoint recovery. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Size of a block above which Spark memory maps when reading a block from disk. + /// + /// Default unit is bytes, unless specified otherwise. + /// This prevents Spark from memory mapping very small blocks. + /// In general, memory mapping has high overhead for blocks close to or below the page size of the operating system. + /// + /// Default: `2.mib` + @Since { version = "0.9.2" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.storage.memoryMapThreshold`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.storage.memoryMapThreshold`. +//documentation +//> Size of a block above which Spark memory maps when reading a block from disk. +//> +//> Default unit is bytes, unless specified otherwise. +//> This prevents Spark from memory mapping very small blocks. +//> In general, memory mapping has high overhead for blocks close to or below the page size of the operating system. +//> +//> Default: `2.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// The file output committer algorithm version, valid algorithm version number: 1 or 2. + /// + /// Note that 2 may cause a correctness issue like MAPREDUCE-7282. + /// + /// Default: `1` + @Since { version = "2.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.hadoop.mapreduce.fileoutputcommitter.algorithm.version`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.hadoop.mapreduce.fileoutputcommitter.algorithm.version`. +//documentation +//> The file output committer algorithm version, valid algorithm version number: 1 or 2. +//> +//> Note that 2 may cause a correctness issue like MAPREDUCE-7282. +//> +//> Default: `1` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Whether to write per-stage peaks of executor metrics (for each executor) to the event log. + /// + /// *Note:* The metrics are polled (collected) and sent in the executor heartbeat, and this is always done; this configuration is only to determine if aggregated metric peaks are written to the event log. + /// + /// Default: `false` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.eventLog.logStageExecutorMetrics`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.eventLog.logStageExecutorMetrics`. +//documentation +//> Whether to write per-stage peaks of executor metrics (for each executor) to the event log. +//> +//> *Note:* The metrics are polled (collected) and sent in the executor heartbeat, and this is always done; this configuration is only to determine if aggregated metric peaks are written to the event log. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Whether to collect process tree metrics (from the /proc filesystem) when collecting executor metrics. + /// + /// *Note:* The process tree metrics are collected only if the /proc filesystem exists. + /// + /// Default: `false` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.processTreeMetrics.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.processTreeMetrics.enabled`. +//documentation +//> Whether to collect process tree metrics (from the /proc filesystem) when collecting executor metrics. +//> +//> *Note:* The process tree metrics are collected only if the /proc filesystem exists. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// How often to collect executor metrics (in milliseconds). + /// + /// If 0, the polling is done on executor heartbeats (thus at the heartbeat interval, specified by `spark.executor.heartbeatInterval`). + /// If positive, the polling is done at this interval. + /// + /// Default: `0` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.executor.metrics.pollingInterval`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.executor.metrics.pollingInterval`. +//documentation +//> How often to collect executor metrics (in milliseconds). +//> +//> If 0, the polling is done on executor heartbeats (thus at the heartbeat interval, specified by `spark.executor.heartbeatInterval`). +//> If positive, the polling is done at this interval. +//> +//> Default: `0` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Maximum message size (in MiB) to allow in "control plane" communication; generally only applies to map output size information sent between executors and the driver. + /// + /// Increase this if you are running jobs with many thousands of map and reduce tasks and see messages about the RPC message size. + /// + /// Default: `128` + @Since { version = "2.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.rpc.message.maxSize`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.rpc.message.maxSize`. +//documentation +//> Maximum message size (in MiB) to allow in "control plane" communication; generally only applies to map output size information sent between executors and the driver. +//> +//> Increase this if you are running jobs with many thousands of map and reduce tasks and see messages about the RPC message size. +//> +//> Default: `128` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Port for all block managers to listen on. + /// + /// These exist on both the driver and the executors. + /// + /// Default: (random) + @Since { version = "1.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.blockManager.port`: UInt16? +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.blockManager.port`. +//documentation +//> Port for all block managers to listen on. +//> +//> These exist on both the driver and the executors. +//> +//> Default: (random) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt16# + + /// Driver-specific port for the block manager to listen on, for cases where it cannot use the same configuration as executors. + /// + /// Default: (value of spark.blockManager.port) + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.blockManager.port`: UInt16? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.blockManager.port`. +//documentation +//> Driver-specific port for the block manager to listen on, for cases where it cannot use the same configuration as executors. +//> +//> Default: (value of spark.blockManager.port) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt16# + + /// Hostname or IP address where to bind listening sockets. + /// + /// This config overrides the SPARK_LOCAL_IP environment variable (see below). + /// + ///
It also allows a different address from the local one to be advertised to executors or external systems. + /// This is useful, for example, when running containers with bridged networking. + /// For this to properly work, + /// the different ports used by the driver (RPC, block manager and UI) need to be forwarded from the + /// container's host. + /// + /// Default: (value of spark.driver.host) + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.bindAddress`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.bindAddress`. +//documentation +//> Hostname or IP address where to bind listening sockets. +//> +//> This config overrides the SPARK_LOCAL_IP environment variable (see below). +//> +//>
It also allows a different address from the local one to be advertised to executors or external systems. +//> This is useful, for example, when running containers with bridged networking. +//> For this to properly work, +//> the different ports used by the driver (RPC, block manager and UI) need to be forwarded from the +//> container's host. +//> +//> Default: (value of spark.driver.host) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Hostname or IP address for the driver. + /// + /// This is used for communicating with the executors and the standalone Master. + /// + /// Default: (local hostname) + @Since { version = "0.7.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.host`: String? +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.host`. +//documentation +//> Hostname or IP address for the driver. +//> +//> This is used for communicating with the executors and the standalone Master. +//> +//> Default: (local hostname) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Port for the driver to listen on. + /// + /// This is used for communicating with the executors and the standalone Master. + /// + /// Default: (random) + @Since { version = "0.7.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.driver.port`: UInt16? +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.driver.port`. +//documentation +//> Port for the driver to listen on. +//> +//> This is used for communicating with the executors and the standalone Master. +//> +//> Default: (random) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt16# + + /// Length of the accept queue for the RPC server. + /// + /// For large applications, this value may need to be increased, so that incoming connections are not dropped when a large number of connections arrives in a short period of time. + /// + /// Default: `64` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.rpc.io.backLog`: Int? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.rpc.io.backLog`. +//documentation +//> Length of the accept queue for the RPC server. +//> +//> For large applications, this value may need to be increased, so that incoming connections are not dropped when a large number of connections arrives in a short period of time. +//> +//> Default: `64` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Default timeout for all network interactions. + /// + /// This config will be used in place of `spark.storage.blockManagerHeartbeatTimeoutMs`, `spark.shuffle.io.connectionTimeout`, `spark.rpc.askTimeout` or `spark.rpc.lookupTimeout` if they are not configured. + /// + /// Default: `120.s` + @Since { version = "1.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.network.timeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.network.timeout`. +//documentation +//> Default timeout for all network interactions. +//> +//> This config will be used in place of `spark.storage.blockManagerHeartbeatTimeoutMs`, `spark.shuffle.io.connectionTimeout`, `spark.rpc.askTimeout` or `spark.rpc.lookupTimeout` if they are not configured. +//> +//> Default: `120.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// If enabled then off-heap buffer allocations are preferred by the shared allocators. + /// + /// Off-heap buffers are used to reduce garbage collection during shuffle and cache block transfer. + /// For environments where off-heap memory is tightly limited, users may wish to turn this off to force all allocations to be on-heap. + /// + /// Default: `true` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.network.io.preferDirectBufs`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.network.io.preferDirectBufs`. +//documentation +//> If enabled then off-heap buffer allocations are preferred by the shared allocators. +//> +//> Off-heap buffers are used to reduce garbage collection during shuffle and cache block transfer. +//> For environments where off-heap memory is tightly limited, users may wish to turn this off to force all allocations to be on-heap. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Maximum number of retries when binding to a port before giving up. + /// + /// When a port is given a specific value (non 0), each subsequent retry will increment the port used in the previous attempt by 1 before retrying. + /// This essentially allows it to try a range of ports from the start port specified to port + maxRetries. + /// + /// Default: `16` + @Since { version = "1.1.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.port.maxRetries`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.port.maxRetries`. +//documentation +//> Maximum number of retries when binding to a port before giving up. +//> +//> When a port is given a specific value (non 0), each subsequent retry will increment the port used in the previous attempt by 1 before retrying. +//> This essentially allows it to try a range of ports from the start port specified to port + maxRetries. +//> +//> Default: `16` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Number of times to retry before an RPC task gives up. + /// + /// An RPC task will run at most times of this number. + /// + /// Default: `3` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.rpc.numRetries`: Int? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.rpc.numRetries`. +//documentation +//> Number of times to retry before an RPC task gives up. +//> +//> An RPC task will run at most times of this number. +//> +//> Default: `3` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Duration for an RPC ask operation to wait before retrying. + /// + /// Default: `3.s` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.rpc.retry.wait`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.rpc.retry.wait`. +//documentation +//> Duration for an RPC ask operation to wait before retrying. +//> +//> Default: `3.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Duration for an RPC ask operation to wait before timing out. + /// + /// Default: `spark.network.timeout` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.rpc.askTimeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.rpc.askTimeout`. +//documentation +//> Duration for an RPC ask operation to wait before timing out. +//> +//> Default: `spark.network.timeout` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Duration for an RPC remote endpoint lookup operation to wait before timing out. + /// + /// Default: `120.s` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.rpc.lookupTimeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.rpc.lookupTimeout`. +//documentation +//> Duration for an RPC remote endpoint lookup operation to wait before timing out. +//> +//> Default: `120.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Remote block will be fetched to disk when size of the block is above this threshold in bytes. + /// + /// This is to avoid a giant request takes too much memory. + /// Note this configuration will affect both shuffle fetch and block manager remote block fetch. + /// For users who enabled external shuffle service, this feature can only work when external shuffle service is at least 2.3.0. + /// + /// Default: `200.mib` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.network.maxRemoteBlockSizeFetchToMem`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.network.maxRemoteBlockSizeFetchToMem`. +//documentation +//> Remote block will be fetched to disk when size of the block is above this threshold in bytes. +//> +//> This is to avoid a giant request takes too much memory. +//> Note this configuration will affect both shuffle fetch and block manager remote block fetch. +//> For users who enabled external shuffle service, this feature can only work when external shuffle service is at least 2.3.0. +//> +//> Default: `200.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Timeout for the established connections between RPC peers to be marked as idled and closed if there are outstanding RPC requests but no traffic on the channel for at least \`connectionTimeout\`. + /// + /// Default: value of spark.network.timeout + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.rpc.io.connectionTimeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.rpc.io.connectionTimeout`. +//documentation +//> Timeout for the established connections between RPC peers to be marked as idled and closed if there are outstanding RPC requests but no traffic on the channel for at least \`connectionTimeout\`. +//> +//> Default: value of spark.network.timeout +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// When running on a [standalone deploy cluster](https://spark.apache.org/docs/latest/spark-standalone.html) or a [Mesos cluster in "coarse-grained" sharing mode](https://spark.apache.org/docs/latest/running-on-mesos.html#mesos-run-modes), the maximum amount of CPU cores to request for the application from across the cluster (not from each machine). + /// + /// If not set, the default will be `spark.deploy.defaultCores` on Spark's standalone cluster manager, or infinite (all available cores) on Mesos. + /// + /// Default: (not set) + @Reserved +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/Reserved# + @Since { version = "0.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.cores.max`: Null? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.cores.max`. +//documentation +//> When running on a [standalone deploy cluster](https://spark.apache.org/docs/latest/spark-standalone.html) or a [Mesos cluster in "coarse-grained" sharing mode](https://spark.apache.org/docs/latest/running-on-mesos.html#mesos-run-modes), the maximum amount of CPU cores to request for the application from across the cluster (not from each machine). +//> +//> If not set, the default will be `spark.deploy.defaultCores` on Spark's standalone cluster manager, or infinite (all available cores) on Mesos. +//> +//> Default: (not set) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# + + /// How long to wait to launch a data-local task before giving up and launching it on a less-local node. + /// + /// The same wait will be used to step through multiple locality levels (process-local, node-local, rack-local and then any). + /// It is also possible to customize the waiting time for each level by setting `spark.locality.wait.node`, etc. + /// You should increase this setting if your tasks are long and see poor locality, but the default usually works well. + /// + /// Default: `3.s` + @Since { version = "0.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.locality.wait`: Duration? +//^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.locality.wait`. +//documentation +//> How long to wait to launch a data-local task before giving up and launching it on a less-local node. +//> +//> The same wait will be used to step through multiple locality levels (process-local, node-local, rack-local and then any). +//> It is also possible to customize the waiting time for each level by setting `spark.locality.wait.node`, etc. +//> You should increase this setting if your tasks are long and see poor locality, but the default usually works well. +//> +//> Default: `3.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Customize the locality wait for node locality. + /// + /// For example, you can set this to 0 to skip node locality and search immediately for rack locality (if your cluster has rack information). + /// + /// Default: `spark.locality.wait` + @Since { version = "0.8.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.locality.wait.node`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.locality.wait.node`. +//documentation +//> Customize the locality wait for node locality. +//> +//> For example, you can set this to 0 to skip node locality and search immediately for rack locality (if your cluster has rack information). +//> +//> Default: `spark.locality.wait` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Customize the locality wait for process locality. + /// + /// This affects tasks that attempt to access cached data in a particular executor process. + /// + /// Default: `spark.locality.wait` + @Since { version = "0.8.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.locality.wait.process`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.locality.wait.process`. +//documentation +//> Customize the locality wait for process locality. +//> +//> This affects tasks that attempt to access cached data in a particular executor process. +//> +//> Default: `spark.locality.wait` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Customize the locality wait for rack locality. + /// + /// Default: `spark.locality.wait` + @Since { version = "0.8.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.locality.wait.rack`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.locality.wait.rack`. +//documentation +//> Customize the locality wait for rack locality. +//> +//> Default: `spark.locality.wait` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Maximum amount of time to wait for resources to register before scheduling begins. + /// + /// Default: `30.s` + @Since { version = "1.1.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.maxRegisteredResourcesWaitingTime`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.maxRegisteredResourcesWaitingTime`. +//documentation +//> Maximum amount of time to wait for resources to register before scheduling begins. +//> +//> Default: `30.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// The minimum ratio of registered resources (registered resources / total expected resources) (resources are executors in yarn mode and Kubernetes mode, CPU cores in standalone mode and Mesos coarse-grained mode \['spark.cores.max' value is total expected resources for Mesos coarse-grained mode\] ) to wait for before scheduling begins. + /// + /// Specified as a double between 0.0 and 1.0. Regardless of whether the minimum ratio of resources has been reached, the maximum amount of time it will wait before scheduling begins is controlled by config `spark.scheduler.maxRegisteredResourcesWaitingTime`. + /// + /// Default: 0.8 for KUBERNETES mode; 0.8 for YARN mode; 0.0 for standalone mode and Mesos coarse-grained mode + @Since { version = "1.1.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.minRegisteredResourcesRatio`: Float? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.minRegisteredResourcesRatio`. +//documentation +//> The minimum ratio of registered resources (registered resources / total expected resources) (resources are executors in yarn mode and Kubernetes mode, CPU cores in standalone mode and Mesos coarse-grained mode \`'spark.cores.max' value is total expected resources for Mesos coarse-grained mode\` ) to wait for before scheduling begins. +//> +//> Specified as a double between 0.0 and 1.0. Regardless of whether the minimum ratio of resources has been reached, the maximum amount of time it will wait before scheduling begins is controlled by config `spark.scheduler.maxRegisteredResourcesWaitingTime`. +//> +//> Default: 0.8 for KUBERNETES mode; 0.8 for YARN mode; 0.0 for standalone mode and Mesos coarse-grained mode +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + + /// The [scheduling mode](https://spark.apache.org/docs/latest/job-scheduling.html#scheduling-within-an-application) between jobs submitted to the same SparkContext. + /// + /// Can be set to `FAIR` to use fair sharing instead of queueing jobs one after another. + /// Useful for multi-user services. + /// + /// Default: `"FIFO"` + @Since { version = "0.8.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.mode`: String? +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.mode`. +//documentation +//> The [scheduling mode](https://spark.apache.org/docs/latest/job-scheduling.html#scheduling-within-an-application) between jobs submitted to the same SparkContext. +//> +//> Can be set to `FAIR` to use fair sharing instead of queueing jobs one after another. +//> Useful for multi-user services. +//> +//> Default: `"FIFO"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The interval length for the scheduler to revive the worker resource offers to run tasks. + /// + /// Default: `1.s` + @Since { version = "0.8.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.revive.interval`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.revive.interval`. +//documentation +//> The interval length for the scheduler to revive the worker resource offers to run tasks. +//> +//> Default: `1.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// The default capacity for event queues. + /// + /// Spark will try to initialize an event queue using capacity specified by \`spark.scheduler.listenerbus.eventqueue.queueName.capacity\` first. + /// If it's not configured, Spark will use the default capacity specified by this config. + /// Note that capacity must be greater than 0. Consider increasing value (e.g. 20000) if listener events are dropped. + /// Increasing this value may result in the driver using more memory. + /// + /// Default: `10000` + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.listenerbus.eventqueue.capacity`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.listenerbus.eventqueue.capacity`. +//documentation +//> The default capacity for event queues. +//> +//> Spark will try to initialize an event queue using capacity specified by \`spark.scheduler.listenerbus.eventqueue.queueName.capacity\` first. +//> If it's not configured, Spark will use the default capacity specified by this config. +//> Note that capacity must be greater than 0. Consider increasing value (e.g. 20000) if listener events are dropped. +//> Increasing this value may result in the driver using more memory. +//> +//> Default: `10000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Capacity for shared event queue in Spark listener bus, which hold events for external listener(s) that register to the listener bus. + /// + /// Consider increasing value, if the listener events corresponding to shared queue are dropped. + /// Increasing this value may result in the driver using more memory. + /// + /// Default: `spark.scheduler.listenerbus.eventqueue.capacity` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.listenerbus.eventqueue.shared.capacity`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.listenerbus.eventqueue.shared.capacity`. +//documentation +//> Capacity for shared event queue in Spark listener bus, which hold events for external listener(s) that register to the listener bus. +//> +//> Consider increasing value, if the listener events corresponding to shared queue are dropped. +//> Increasing this value may result in the driver using more memory. +//> +//> Default: `spark.scheduler.listenerbus.eventqueue.capacity` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Capacity for appStatus event queue, which hold events for internal application status listeners. + /// + /// Consider increasing value, if the listener events corresponding to appStatus queue are dropped. + /// Increasing this value may result in the driver using more memory. + /// + /// Default: `spark.scheduler.listenerbus.eventqueue.capacity` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.listenerbus.eventqueue.appStatus.capacity`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.listenerbus.eventqueue.appStatus.capacity`. +//documentation +//> Capacity for appStatus event queue, which hold events for internal application status listeners. +//> +//> Consider increasing value, if the listener events corresponding to appStatus queue are dropped. +//> Increasing this value may result in the driver using more memory. +//> +//> Default: `spark.scheduler.listenerbus.eventqueue.capacity` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Capacity for executorManagement event queue in Spark listener bus, which hold events for internal executor management listeners. + /// + /// Consider increasing value if the listener events corresponding to executorManagement queue are dropped. + /// Increasing this value may result in the driver using more memory. + /// + /// Default: `spark.scheduler.listenerbus.eventqueue.capacity` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.listenerbus.eventqueue.executorManagement.capacity`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.listenerbus.eventqueue.executorManagement.capacity`. +//documentation +//> Capacity for executorManagement event queue in Spark listener bus, which hold events for internal executor management listeners. +//> +//> Consider increasing value if the listener events corresponding to executorManagement queue are dropped. +//> Increasing this value may result in the driver using more memory. +//> +//> Default: `spark.scheduler.listenerbus.eventqueue.capacity` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Capacity for eventLog queue in Spark listener bus, which hold events for Event logging listeners that write events to eventLogs. + /// + /// Consider increasing value if the listener events corresponding to eventLog queue are dropped. + /// Increasing this value may result in the driver using more memory. + /// + /// Default: `spark.scheduler.listenerbus.eventqueue.capacity` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.listenerbus.eventqueue.eventLog.capacity`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.listenerbus.eventqueue.eventLog.capacity`. +//documentation +//> Capacity for eventLog queue in Spark listener bus, which hold events for Event logging listeners that write events to eventLogs. +//> +//> Consider increasing value if the listener events corresponding to eventLog queue are dropped. +//> Increasing this value may result in the driver using more memory. +//> +//> Default: `spark.scheduler.listenerbus.eventqueue.capacity` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Capacity for streams queue in Spark listener bus, which hold events for internal streaming listener. + /// + /// Consider increasing value if the listener events corresponding to streams queue are dropped. + /// Increasing this value may result in the driver using more memory. + /// + /// Default: `spark.scheduler.listenerbus.eventqueue.capacity` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.listenerbus.eventqueue.streams.capacity`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.listenerbus.eventqueue.streams.capacity`. +//documentation +//> Capacity for streams queue in Spark listener bus, which hold events for internal streaming listener. +//> +//> Consider increasing value if the listener events corresponding to streams queue are dropped. +//> Increasing this value may result in the driver using more memory. +//> +//> Default: `spark.scheduler.listenerbus.eventqueue.capacity` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// If set to "true", Spark will merge ResourceProfiles when different profiles are specified in RDDs that get combined into a single stage. + /// + /// When they are merged, Spark chooses the maximum of each resource and creates a new ResourceProfile. + /// The default of false results in Spark throwing an exception if multiple different ResourceProfiles are found in RDDs going into the same stage. + /// + /// Default: `false` + @Since { version = "3.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.resource.profileMergeConflicts`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.resource.profileMergeConflicts`. +//documentation +//> If set to "true", Spark will merge ResourceProfiles when different profiles are specified in RDDs that get combined into a single stage. +//> +//> When they are merged, Spark chooses the maximum of each resource and creates a new ResourceProfile. +//> The default of false results in Spark throwing an exception if multiple different ResourceProfiles are found in RDDs going into the same stage. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The timeout in seconds to wait to acquire a new executor and schedule a task before aborting a TaskSet which is unschedulable because all executors are excluded due to task failures. + /// + /// Default: `120.s` + @Since { version = "2.4.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.excludeOnFailure.unschedulableTaskSetTimeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.excludeOnFailure.unschedulableTaskSetTimeout`. +//documentation +//> The timeout in seconds to wait to acquire a new executor and schedule a task before aborting a TaskSet which is unschedulable because all executors are excluded due to task failures. +//> +//> Default: `120.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// If set to "true", prevent Spark from scheduling tasks on executors that have been excluded due to too many task failures. + /// + /// The algorithm used to exclude executors and nodes can be further controlled by the other "spark.excludeOnFailure" configuration options. + /// + /// Default: `false` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.excludeOnFailure.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.excludeOnFailure.enabled`. +//documentation +//> If set to "true", prevent Spark from scheduling tasks on executors that have been excluded due to too many task failures. +//> +//> The algorithm used to exclude executors and nodes can be further controlled by the other "spark.excludeOnFailure" configuration options. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// (Experimental) How long a node or executor is excluded for the entire application, before it is unconditionally removed from the excludelist to attempt running new tasks. + /// + /// Default: `1.h` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.excludeOnFailure.timeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.excludeOnFailure.timeout`. +//documentation +//> (Experimental) How long a node or executor is excluded for the entire application, before it is unconditionally removed from the excludelist to attempt running new tasks. +//> +//> Default: `1.h` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// (Experimental) For a given task, how many times it can be retried on one executor before the executor is excluded for that task. + /// + /// Default: `1` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.excludeOnFailure.task.maxTaskAttemptsPerExecutor`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.excludeOnFailure.task.maxTaskAttemptsPerExecutor`. +//documentation +//> (Experimental) For a given task, how many times it can be retried on one executor before the executor is excluded for that task. +//> +//> Default: `1` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// (Experimental) For a given task, how many times it can be retried on one node, before the entire node is excluded for that task. + /// + /// Default: `2` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.excludeOnFailure.task.maxTaskAttemptsPerNode`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.excludeOnFailure.task.maxTaskAttemptsPerNode`. +//documentation +//> (Experimental) For a given task, how many times it can be retried on one node, before the entire node is excluded for that task. +//> +//> Default: `2` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// (Experimental) How many different tasks must fail on one executor, within one stage, before the executor is excluded for that stage. + /// + /// Default: `2` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.excludeOnFailure.stage.maxFailedTasksPerExecutor`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.excludeOnFailure.stage.maxFailedTasksPerExecutor`. +//documentation +//> (Experimental) How many different tasks must fail on one executor, within one stage, before the executor is excluded for that stage. +//> +//> Default: `2` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// (Experimental) How many different executors are marked as excluded for a given stage, before the entire node is marked as failed for the stage. + /// + /// Default: `2` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.excludeOnFailure.stage.maxFailedExecutorsPerNode`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.excludeOnFailure.stage.maxFailedExecutorsPerNode`. +//documentation +//> (Experimental) How many different executors are marked as excluded for a given stage, before the entire node is marked as failed for the stage. +//> +//> Default: `2` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// (Experimental) How many different tasks must fail on one executor, in successful task sets, before the executor is excluded for the entire application. + /// + /// Excluded executors will be automatically added back to the pool of available resources after the timeout specified by `spark.excludeOnFailure.timeout`. + /// Note that with dynamic allocation, though, the executors may get marked as idle and be reclaimed by the cluster manager. + /// + /// Default: `2` + @Since { version = "2.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.excludeOnFailure.application.maxFailedTasksPerExecutor`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.excludeOnFailure.application.maxFailedTasksPerExecutor`. +//documentation +//> (Experimental) How many different tasks must fail on one executor, in successful task sets, before the executor is excluded for the entire application. +//> +//> Excluded executors will be automatically added back to the pool of available resources after the timeout specified by `spark.excludeOnFailure.timeout`. +//> Note that with dynamic allocation, though, the executors may get marked as idle and be reclaimed by the cluster manager. +//> +//> Default: `2` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// (Experimental) How many different executors must be excluded for the entire application, before the node is excluded for the entire application. + /// + /// Excluded nodes will be automatically added back to the pool of available resources after the timeout specified by `spark.excludeOnFailure.timeout`. + /// Note that with dynamic allocation, though, the executors on the node may get marked as idle and be reclaimed by the cluster manager. + /// + /// Default: `2` + @Since { version = "2.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.excludeOnFailure.application.maxFailedExecutorsPerNode`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.excludeOnFailure.application.maxFailedExecutorsPerNode`. +//documentation +//> (Experimental) How many different executors must be excluded for the entire application, before the node is excluded for the entire application. +//> +//> Excluded nodes will be automatically added back to the pool of available resources after the timeout specified by `spark.excludeOnFailure.timeout`. +//> Note that with dynamic allocation, though, the executors on the node may get marked as idle and be reclaimed by the cluster manager. +//> +//> Default: `2` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// (Experimental) If set to "true", allow Spark to automatically kill the executors when they are excluded on fetch failure or excluded for the entire application, as controlled by spark.killExcludedExecutors.application.\*. + /// + /// Note that, when an entire node is added excluded, all of the executors on that node will be killed. + /// + /// Default: `false` + @Since { version = "2.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.excludeOnFailure.killExcludedExecutors`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.excludeOnFailure.killExcludedExecutors`. +//documentation +//> (Experimental) If set to "true", allow Spark to automatically kill the executors when they are excluded on fetch failure or excluded for the entire application, as controlled by spark.killExcludedExecutors.application.\*. +//> +//> Note that, when an entire node is added excluded, all of the executors on that node will be killed. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// (Experimental) If set to "true", Spark will exclude the executor immediately when a fetch failure happens. + /// + /// If external shuffle service is enabled, then the whole node will be excluded. + /// + /// Default: `false` + @Since { version = "2.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.excludeOnFailure.application.fetchFailure.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.excludeOnFailure.application.fetchFailure.enabled`. +//documentation +//> (Experimental) If set to "true", Spark will exclude the executor immediately when a fetch failure happens. +//> +//> If external shuffle service is enabled, then the whole node will be excluded. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// If set to "true", performs speculative execution of tasks. + /// + /// This means if one or more tasks are running slowly in a stage, they will be re-launched. + /// + /// Default: `false` + @Since { version = "0.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.speculation`: Boolean? +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.speculation`. +//documentation +//> If set to "true", performs speculative execution of tasks. +//> +//> This means if one or more tasks are running slowly in a stage, they will be re-launched. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// How often Spark will check for tasks to speculate. + /// + /// Default: `100.ms` + @Since { version = "0.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.speculation.interval`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.speculation.interval`. +//documentation +//> How often Spark will check for tasks to speculate. +//> +//> Default: `100.ms` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// How many times slower a task is than the median to be considered for speculation. + /// + /// Default: `1.5` + @Since { version = "0.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.speculation.multiplier`: Float? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.speculation.multiplier`. +//documentation +//> How many times slower a task is than the median to be considered for speculation. +//> +//> Default: `1.5` +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + + /// Fraction of tasks which must be complete before speculation is enabled for a particular stage. + /// + /// Default: `0.75` + @Since { version = "0.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.speculation.quantile`: Float? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.speculation.quantile`. +//documentation +//> Fraction of tasks which must be complete before speculation is enabled for a particular stage. +//> +//> Default: `0.75` +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + + /// Minimum amount of time a task runs before being considered for speculation. + /// + /// This can be used to avoid launching speculative copies of tasks that are very short. + /// + /// Default: `100.ms` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.speculation.minTaskRuntime`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.speculation.minTaskRuntime`. +//documentation +//> Minimum amount of time a task runs before being considered for speculation. +//> +//> This can be used to avoid launching speculative copies of tasks that are very short. +//> +//> Default: `100.ms` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Task duration after which scheduler would try to speculative run the task. + /// + /// If provided, tasks would be speculatively run if current stage contains less tasks than or equal to the number of slots on a single executor and the task is taking longer time than the threshold. + /// This config helps speculate stage with very few tasks. + /// Regular speculation configs may also apply if the executor slots are large enough. + /// E.g. tasks might be re-launched if there are enough successful runs even though the threshold hasn't been reached. + /// The number of slots is computed based on the conf values of spark.executor.cores and spark.task.cpus minimum 1. Default unit is bytes, unless otherwise specified. + /// + /// Default: `null` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.speculation.task.duration.threshold`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.speculation.task.duration.threshold`. +//documentation +//> Task duration after which scheduler would try to speculative run the task. +//> +//> If provided, tasks would be speculatively run if current stage contains less tasks than or equal to the number of slots on a single executor and the task is taking longer time than the threshold. +//> This config helps speculate stage with very few tasks. +//> Regular speculation configs may also apply if the executor slots are large enough. +//> E.g. tasks might be re-launched if there are enough successful runs even though the threshold hasn't been reached. +//> The number of slots is computed based on the conf values of spark.executor.cores and spark.task.cpus minimum 1. Default unit is bytes, unless otherwise specified. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Number of cores to allocate for each task. + /// + /// Default: `1` + @Since { version = "0.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.task.cpus`: Int? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.task.cpus`. +//documentation +//> Number of cores to allocate for each task. +//> +//> Default: `1` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Amount of a particular resource type to allocate for each task, note that this can be a double. + /// + /// If this is specified you must also provide the executor config `spark.executor.resource.{resourceName}.amount` and any corresponding discovery configs so that your executors are created with that resource type. + /// In addition to whole amounts, a fractional amount (for example, 0.25, which means 1/4th of a resource) may be specified. + /// Fractional amounts must be less than or equal to 0.5, or in other words, the minimum amount of resource sharing is 2 tasks per resource. + /// Additionally, fractional amounts are floored in order to assign resource slots (e.g. a 0.2222 configuration, or 1/0.2222 slots will become 4 tasks/resource, not 5). + /// + /// Default: `1` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.task.resource.{resourceName}.amount`: Mapping? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.task.resource.{resourceName}.amount`. +//documentation +//> Amount of a particular resource type to allocate for each task, note that this can be a double. +//> +//> If this is specified you must also provide the executor config `spark.executor.resource.{resourceName}.amount` and any corresponding discovery configs so that your executors are created with that resource type. +//> In addition to whole amounts, a fractional amount (for example, 0.25, which means 1/4th of a resource) may be specified. +//> Fractional amounts must be less than or equal to 0.5, or in other words, the minimum amount of resource sharing is 2 tasks per resource. +//> Additionally, fractional amounts are floored in order to assign resource slots (e.g. a 0.2222 configuration, or 1/0.2222 slots will become 4 tasks/resource, not 5). +//> +//> Default: `1` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/ResourceName# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Number of continuous failures of any particular task before giving up on the job. + /// + /// The total number of failures spread across different tasks will not cause the job to fail; a particular task has to fail this number of attempts continuously. + /// If any attempt succeeds, the failure count for the task will be reset. + /// Should be greater than or equal to 1. Number of allowed retries = this value - 1. + /// + /// Default: `4` + @Since { version = "0.8.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.task.maxFailures`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.task.maxFailures`. +//documentation +//> Number of continuous failures of any particular task before giving up on the job. +//> +//> The total number of failures spread across different tasks will not cause the job to fail; a particular task has to fail this number of attempts continuously. +//> If any attempt succeeds, the failure count for the task will be reset. +//> Should be greater than or equal to 1. Number of allowed retries = this value - 1. +//> +//> Default: `4` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Enables monitoring of killed / interrupted tasks. + /// + /// When set to true, any task which is killed will be monitored by the executor until that task actually finishes executing. + /// See the other `spark.task.reaper.*` configurations for details on how to control the exact behavior of this monitoring. + /// When set to false (the default), task killing will use an older code path which lacks such monitoring. + /// + /// Default: `false` + @Since { version = "2.0.3" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.task.reaper.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.task.reaper.enabled`. +//documentation +//> Enables monitoring of killed / interrupted tasks. +//> +//> When set to true, any task which is killed will be monitored by the executor until that task actually finishes executing. +//> See the other `spark.task.reaper.*` configurations for details on how to control the exact behavior of this monitoring. +//> When set to false (the default), task killing will use an older code path which lacks such monitoring. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// When `spark.task.reaper.enabled = true`, this setting controls the frequency at which executors will poll the status of killed tasks. + /// + /// If a killed task is still running when polled then a warning will be logged and, by default, a thread-dump of the task will be logged (this thread dump can be disabled via the `spark.task.reaper.threadDump` setting, which is documented below). + /// + /// Default: `10.s` + @Since { version = "2.0.3" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.task.reaper.pollingInterval`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.task.reaper.pollingInterval`. +//documentation +//> When `spark.task.reaper.enabled = true`, this setting controls the frequency at which executors will poll the status of killed tasks. +//> +//> If a killed task is still running when polled then a warning will be logged and, by default, a thread-dump of the task will be logged (this thread dump can be disabled via the `spark.task.reaper.threadDump` setting, which is documented below). +//> +//> Default: `10.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// When `spark.task.reaper.enabled = true`, this setting controls whether task thread dumps are logged during periodic polling of killed tasks. + /// + /// Set this to false to disable collection of thread dumps. + /// + /// Default: `true` + @Since { version = "2.0.3" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.task.reaper.threadDump`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.task.reaper.threadDump`. +//documentation +//> When `spark.task.reaper.enabled = true`, this setting controls whether task thread dumps are logged during periodic polling of killed tasks. +//> +//> Set this to false to disable collection of thread dumps. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// When `spark.task.reaper.enabled = true`, this setting specifies a timeout after which the executor JVM will kill itself if a killed task has not stopped running. + /// + /// The default value, -1, disables this mechanism and prevents the executor from self-destructing. + /// The purpose of this setting is to act as a safety-net to prevent runaway noncancellable tasks from rendering an executor unusable. + /// + /// Default: `-1` + @Since { version = "2.0.3" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.task.reaper.killTimeout`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.task.reaper.killTimeout`. +//documentation +//> When `spark.task.reaper.enabled = true`, this setting specifies a timeout after which the executor JVM will kill itself if a killed task has not stopped running. +//> +//> The default value, -1, disables this mechanism and prevents the executor from self-destructing. +//> The purpose of this setting is to act as a safety-net to prevent runaway noncancellable tasks from rendering an executor unusable. +//> +//> Default: `-1` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Number of consecutive stage attempts allowed before a stage is aborted. + /// + /// Default: `4` + @Since { version = "2.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.stage.maxConsecutiveAttempts`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.stage.maxConsecutiveAttempts`. +//documentation +//> Number of consecutive stage attempts allowed before a stage is aborted. +//> +//> Default: `4` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// The timeout in seconds for each `barrier()` call from a barrier task. + /// + /// If the coordinator didn't receive all the sync messages from barrier tasks within the configured time, throw a SparkException to fail all the tasks. + /// The default value is set to 31536000(3600 \* 24 \* 365) so the `barrier()` call shall wait for one year. + /// + /// Default: `365.0` + @Since { version = "2.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.barrier.sync.timeout`: Float? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.barrier.sync.timeout`. +//documentation +//> The timeout in seconds for each `barrier()` call from a barrier task. +//> +//> If the coordinator didn't receive all the sync messages from barrier tasks within the configured time, throw a SparkException to fail all the tasks. +//> The default value is set to 31536000(3600 \* 24 \* 365) so the `barrier()` call shall wait for one year. +//> +//> Default: `365.0` +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + + /// Time in seconds to wait between a max concurrent tasks check failure and the next check. + /// + /// A max concurrent tasks check ensures the cluster can launch more concurrent tasks than required by a barrier stage on job submitted. + /// The check can fail in case a cluster has just started and not enough executors have registered, so we wait for a little while and try to perform the check again. + /// If the check fails more than a configured max failure times for a job then fail current job submission. + /// Note this config only applies to jobs that contain one or more barrier stages, we won't perform the check on non-barrier jobs. + /// + /// Default: `15.s` + @Since { version = "2.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.barrier.maxConcurrentTasksCheck.interval`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.barrier.maxConcurrentTasksCheck.interval`. +//documentation +//> Time in seconds to wait between a max concurrent tasks check failure and the next check. +//> +//> A max concurrent tasks check ensures the cluster can launch more concurrent tasks than required by a barrier stage on job submitted. +//> The check can fail in case a cluster has just started and not enough executors have registered, so we wait for a little while and try to perform the check again. +//> If the check fails more than a configured max failure times for a job then fail current job submission. +//> Note this config only applies to jobs that contain one or more barrier stages, we won't perform the check on non-barrier jobs. +//> +//> Default: `15.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Number of max concurrent tasks check failures allowed before fail a job submission. + /// + /// A max concurrent tasks check ensures the cluster can launch more concurrent tasks than required by a barrier stage on job submitted. + /// The check can fail in case a cluster has just started and not enough executors have registered, so we wait for a little while and try to perform the check again. + /// If the check fails more than a configured max failure times for a job then fail current job submission. + /// Note this config only applies to jobs that contain one or more barrier stages, we won't perform the check on non-barrier jobs. + /// + /// Default: `40` + @Since { version = "2.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.scheduler.barrier.maxConcurrentTasksCheck.maxFailures`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.scheduler.barrier.maxConcurrentTasksCheck.maxFailures`. +//documentation +//> Number of max concurrent tasks check failures allowed before fail a job submission. +//> +//> A max concurrent tasks check ensures the cluster can launch more concurrent tasks than required by a barrier stage on job submitted. +//> The check can fail in case a cluster has just started and not enough executors have registered, so we wait for a little while and try to perform the check again. +//> If the check fails more than a configured max failure times for a job then fail current job submission. +//> Note this config only applies to jobs that contain one or more barrier stages, we won't perform the check on non-barrier jobs. +//> +//> Default: `40` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Whether to use dynamic resource allocation, which scales the number of executors registered with this application up and down based on the workload. + /// + /// For more detail, see the description [here](https://spark.apache.org/docs/latest/job-scheduling.html#dynamic-resource-allocation). + /// + /// This requires `spark.shuffle.service.enabled` or `spark.dynamicAllocation.shuffleTracking.enabled` to be set. + /// The following configurations are also relevant: `spark.dynamicAllocation.minExecutors`, `spark.dynamicAllocation.maxExecutors`, and `spark.dynamicAllocation.initialExecutors` `spark.dynamicAllocation.executorAllocationRatio` + /// + /// Default: `false` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.dynamicAllocation.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.dynamicAllocation.enabled`. +//documentation +//> Whether to use dynamic resource allocation, which scales the number of executors registered with this application up and down based on the workload. +//> +//> For more detail, see the description [here](https://spark.apache.org/docs/latest/job-scheduling.html#dynamic-resource-allocation). +//> +//> This requires `spark.shuffle.service.enabled` or `spark.dynamicAllocation.shuffleTracking.enabled` to be set. +//> The following configurations are also relevant: `spark.dynamicAllocation.minExecutors`, `spark.dynamicAllocation.maxExecutors`, and `spark.dynamicAllocation.initialExecutors` `spark.dynamicAllocation.executorAllocationRatio` +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// If dynamic allocation is enabled and an executor has been idle for more than this duration, the executor will be removed. + /// + /// For more detail, see this [description](https://spark.apache.org/docs/latest/job-scheduling.html#resource-allocation-policy). + /// + /// Default: `60.s` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.dynamicAllocation.executorIdleTimeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.dynamicAllocation.executorIdleTimeout`. +//documentation +//> If dynamic allocation is enabled and an executor has been idle for more than this duration, the executor will be removed. +//> +//> For more detail, see this [description](https://spark.apache.org/docs/latest/job-scheduling.html#resource-allocation-policy). +//> +//> Default: `60.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// If dynamic allocation is enabled and an executor which has cached data blocks has been idle for more than this duration, the executor will be removed. + /// + /// For more details, see this [description](https://spark.apache.org/docs/latest/job-scheduling.html#resource-allocation-policy). + /// + /// Default: `infinity` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.dynamicAllocation.cachedExecutorIdleTimeout`: Number? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.dynamicAllocation.cachedExecutorIdleTimeout`. +//documentation +//> If dynamic allocation is enabled and an executor which has cached data blocks has been idle for more than this duration, the executor will be removed. +//> +//> For more details, see this [description](https://spark.apache.org/docs/latest/job-scheduling.html#resource-allocation-policy). +//> +//> Default: `infinity` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// Initial number of executors to run if dynamic allocation is enabled. + /// + /// + /// If \`--num-executors\` (or \`spark.executor.instances\`) is set and larger than this value, it will be used as the initial number of executors. + /// + /// Default: `spark.dynamicAllocation.minExecutors` + @Since { version = "1.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.dynamicAllocation.initialExecutors`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.dynamicAllocation.initialExecutors`. +//documentation +//> Initial number of executors to run if dynamic allocation is enabled. +//> +//> +//> If \`--num-executors\` (or \`spark.executor.instances\`) is set and larger than this value, it will be used as the initial number of executors. +//> +//> Default: `spark.dynamicAllocation.minExecutors` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Upper bound for the number of executors if dynamic allocation is enabled. + /// + /// Default: `infinity` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.dynamicAllocation.maxExecutors`: Number? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.dynamicAllocation.maxExecutors`. +//documentation +//> Upper bound for the number of executors if dynamic allocation is enabled. +//> +//> Default: `infinity` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// Lower bound for the number of executors if dynamic allocation is enabled. + /// + /// Default: `0` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.dynamicAllocation.minExecutors`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.dynamicAllocation.minExecutors`. +//documentation +//> Lower bound for the number of executors if dynamic allocation is enabled. +//> +//> Default: `0` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// By default, the dynamic allocation will request enough executors to maximize the parallelism according to the number of tasks to process. + /// + /// While this minimizes the latency of the job, with small tasks this setting can waste a lot of resources due to executor allocation overhead, as some executor might not even do any work. + /// This setting allows to set a ratio that will be used to reduce the number of executors w.r.t. full parallelism. + /// Defaults to 1.0 to give maximum parallelism. + /// 0.5 will divide the target number of executors by 2 The target number of executors computed by the dynamicAllocation can still be overridden by the `spark.dynamicAllocation.minExecutors` and `spark.dynamicAllocation.maxExecutors` settings + /// + /// Default: `1` + @Since { version = "2.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.dynamicAllocation.executorAllocationRatio`: Float? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.dynamicAllocation.executorAllocationRatio`. +//documentation +//> By default, the dynamic allocation will request enough executors to maximize the parallelism according to the number of tasks to process. +//> +//> While this minimizes the latency of the job, with small tasks this setting can waste a lot of resources due to executor allocation overhead, as some executor might not even do any work. +//> This setting allows to set a ratio that will be used to reduce the number of executors w.r.t. full parallelism. +//> Defaults to 1.0 to give maximum parallelism. +//> 0.5 will divide the target number of executors by 2 The target number of executors computed by the dynamicAllocation can still be overridden by the `spark.dynamicAllocation.minExecutors` and `spark.dynamicAllocation.maxExecutors` settings +//> +//> Default: `1` +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + + /// If dynamic allocation is enabled and there have been pending tasks backlogged for more than this duration, new executors will be requested. + /// + /// For more detail, see this [description](https://spark.apache.org/docs/latest/job-scheduling.html#resource-allocation-policy). + /// + /// Default: `1.s` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.dynamicAllocation.schedulerBacklogTimeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.dynamicAllocation.schedulerBacklogTimeout`. +//documentation +//> If dynamic allocation is enabled and there have been pending tasks backlogged for more than this duration, new executors will be requested. +//> +//> For more detail, see this [description](https://spark.apache.org/docs/latest/job-scheduling.html#resource-allocation-policy). +//> +//> Default: `1.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Same as `spark.dynamicAllocation.schedulerBacklogTimeout`, but used only for subsequent executor requests. + /// + /// For more detail, see this [description](https://spark.apache.org/docs/latest/job-scheduling.html#resource-allocation-policy). + /// + /// Default: `"schedulerBacklogTimeout"` + @Since { version = "1.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.dynamicAllocation.sustainedSchedulerBacklogTimeout`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.dynamicAllocation.sustainedSchedulerBacklogTimeout`. +//documentation +//> Same as `spark.dynamicAllocation.schedulerBacklogTimeout`, but used only for subsequent executor requests. +//> +//> For more detail, see this [description](https://spark.apache.org/docs/latest/job-scheduling.html#resource-allocation-policy). +//> +//> Default: `"schedulerBacklogTimeout"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Enables shuffle file tracking for executors, which allows dynamic allocation without the need for an external shuffle service. + /// + /// This option will try to keep alive executors that are storing shuffle data for active jobs. + /// + /// Default: `false` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.dynamicAllocation.shuffleTracking.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.dynamicAllocation.shuffleTracking.enabled`. +//documentation +//> Enables shuffle file tracking for executors, which allows dynamic allocation without the need for an external shuffle service. +//> +//> This option will try to keep alive executors that are storing shuffle data for active jobs. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// When shuffle tracking is enabled, controls the timeout for executors that are holding shuffle data. + /// + /// The default value means that Spark will rely on the shuffles being garbage collected to be able to release executors. + /// If for some reason garbage collection is not cleaning up shuffles quickly enough, this option can be used to control when to time out executors even when they are storing shuffle data. + /// + /// Default: `infinity` + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.dynamicAllocation.shuffleTracking.timeout`: Number? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.dynamicAllocation.shuffleTracking.timeout`. +//documentation +//> When shuffle tracking is enabled, controls the timeout for executors that are holding shuffle data. +//> +//> The default value means that Spark will rely on the shuffles being garbage collected to be able to release executors. +//> If for some reason garbage collection is not cleaning up shuffles quickly enough, this option can be used to control when to time out executors even when they are storing shuffle data. +//> +//> Default: `infinity` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// Number of threads used in the server thread pool + /// + /// Default: Fall back on spark.rpc.io.serverThreads + @Since { version = "1.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.{driver|executor}.rpc.io.serverThreads`: Mapping<"driver"|"executor", UInt>? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.{driver|executor}.rpc.io.serverThreads`. +//documentation +//> Number of threads used in the server thread pool +//> +//> Default: Fall back on spark.rpc.io.serverThreads +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Number of threads used in the client thread pool + /// + /// Default: Fall back on spark.rpc.io.clientThreads + @Since { version = "1.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.{driver|executor}.rpc.io.clientThreads`: Mapping<"driver"|"executor", UInt>? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.{driver|executor}.rpc.io.clientThreads`. +//documentation +//> Number of threads used in the client thread pool +//> +//> Default: Fall back on spark.rpc.io.clientThreads +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Number of threads used in RPC message dispatcher thread pool + /// + /// Default: Fall back on spark.rpc.netty.dispatcher.numThreads + @Since { version = "3.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.{driver|executor}.rpc.netty.dispatcher.numThreads`: Mapping<"driver"|"executor", UInt>? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.{driver|executor}.rpc.netty.dispatcher.numThreads`. +//documentation +//> Number of threads used in RPC message dispatcher thread pool +//> +//> Default: Fall back on spark.rpc.netty.dispatcher.numThreads +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Enables or disables Spark Streaming's internal backpressure mechanism (since 1.5). + /// + /// This enables the Spark Streaming to control the receiving rate based on the current batch scheduling delays and processing times so that the system receives only as fast as the system can process. + /// Internally, this dynamically sets the maximum receiving rate of receivers. + /// This rate is upper bounded by the values `spark.streaming.receiver.maxRate` and `spark.streaming.kafka.maxRatePerPartition` if they are set (see below). + /// + /// Default: `false` + @Since { version = "1.5.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.backpressure.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.backpressure.enabled`. +//documentation +//> Enables or disables Spark Streaming's internal backpressure mechanism (since 1.5). +//> +//> This enables the Spark Streaming to control the receiving rate based on the current batch scheduling delays and processing times so that the system receives only as fast as the system can process. +//> Internally, this dynamically sets the maximum receiving rate of receivers. +//> This rate is upper bounded by the values `spark.streaming.receiver.maxRate` and `spark.streaming.kafka.maxRatePerPartition` if they are set (see below). +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// This is the initial maximum receiving rate at which each receiver will receive data for the first batch when the backpressure mechanism is enabled. + /// + /// Default: `null` + @Since { version = "2.0.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.backpressure.initialRate`: UInt? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.backpressure.initialRate`. +//documentation +//> This is the initial maximum receiving rate at which each receiver will receive data for the first batch when the backpressure mechanism is enabled. +//> +//> Default: `null` +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Interval at which data received by Spark Streaming receivers is chunked into blocks of data before storing them in Spark. + /// + /// Minimum recommended - 50 ms. See the [performance tuning](https://spark.apache.org/docs/latest/streaming-programming-guide.html#level-of-parallelism-in-data-receiving) section in the Spark Streaming programming guide for more details. + /// + /// Default: `200.ms` + @Since { version = "0.8.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.blockInterval`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.blockInterval`. +//documentation +//> Interval at which data received by Spark Streaming receivers is chunked into blocks of data before storing them in Spark. +//> +//> Minimum recommended - 50 ms. See the [performance tuning](https://spark.apache.org/docs/latest/streaming-programming-guide.html#level-of-parallelism-in-data-receiving) section in the Spark Streaming programming guide for more details. +//> +//> Default: `200.ms` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Maximum rate (number of records per second) at which each receiver will receive data. + /// + /// Effectively, each stream will consume at most this number of records per second. + /// Setting this configuration to 0 or a negative number will put no limit on the rate. + /// See the [deployment guide](https://spark.apache.org/docs/latest/streaming-programming-guide.html#deploying-applications) in the Spark Streaming programming guide for mode details. + /// + /// Default: `null` + @Since { version = "1.0.2" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.receiver.maxRate`: UInt? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.receiver.maxRate`. +//documentation +//> Maximum rate (number of records per second) at which each receiver will receive data. +//> +//> Effectively, each stream will consume at most this number of records per second. +//> Setting this configuration to 0 or a negative number will put no limit on the rate. +//> See the [deployment guide](https://spark.apache.org/docs/latest/streaming-programming-guide.html#deploying-applications) in the Spark Streaming programming guide for mode details. +//> +//> Default: `null` +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Enable write-ahead logs for receivers. + /// + /// All the input data received through receivers will be saved to write-ahead logs that will allow it to be recovered after driver failures. + /// See the [deployment guide](https://spark.apache.org/docs/latest/streaming-programming-guide.html#deploying-applications) in the Spark Streaming programming guide for more details. + /// + /// Default: `false` + @Since { version = "1.2.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.receiver.writeAheadLog.enable`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.receiver.writeAheadLog.enable`. +//documentation +//> Enable write-ahead logs for receivers. +//> +//> All the input data received through receivers will be saved to write-ahead logs that will allow it to be recovered after driver failures. +//> See the [deployment guide](https://spark.apache.org/docs/latest/streaming-programming-guide.html#deploying-applications) in the Spark Streaming programming guide for more details. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Force RDDs generated and persisted by Spark Streaming to be automatically unpersisted from Spark's memory. + /// + /// The raw input data received by Spark Streaming is also automatically cleared. + /// Setting this to false will allow the raw data and persisted RDDs to be accessible outside the streaming application as they will not be cleared automatically. + /// But it comes at the cost of higher memory usage in Spark. + /// + /// Default: `true` + @Since { version = "0.9.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.unpersist`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.unpersist`. +//documentation +//> Force RDDs generated and persisted by Spark Streaming to be automatically unpersisted from Spark's memory. +//> +//> The raw input data received by Spark Streaming is also automatically cleared. +//> Setting this to false will allow the raw data and persisted RDDs to be accessible outside the streaming application as they will not be cleared automatically. +//> But it comes at the cost of higher memory usage in Spark. +//> +//> Default: `true` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// If `true`, Spark shuts down the `StreamingContext` gracefully on JVM shutdown rather than immediately. + /// + /// Default: `false` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.stopGracefullyOnShutdown`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.stopGracefullyOnShutdown`. +//documentation +//> If `true`, Spark shuts down the `StreamingContext` gracefully on JVM shutdown rather than immediately. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Maximum rate (number of records per second) at which data will be read from each Kafka partition when using the new Kafka direct stream API. + /// + /// See the [Kafka Integration guide](https://spark.apache.org/docs/latest/streaming-kafka-0-10-integration.html) for more details. + /// + /// Default: `null` + @Since { version = "1.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.kafka.maxRatePerPartition`: UInt? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.kafka.maxRatePerPartition`. +//documentation +//> Maximum rate (number of records per second) at which data will be read from each Kafka partition when using the new Kafka direct stream API. +//> +//> See the [Kafka Integration guide](https://spark.apache.org/docs/latest/streaming-kafka-0-10-integration.html) for more details. +//> +//> Default: `null` +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Minimum rate (number of records per second) at which data will be read from each Kafka partition when using the new Kafka direct stream API. + /// + /// Default: `1` + @Since { version = "2.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.kafka.minRatePerPartition`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.kafka.minRatePerPartition`. +//documentation +//> Minimum rate (number of records per second) at which data will be read from each Kafka partition when using the new Kafka direct stream API. +//> +//> Default: `1` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Whether to close the file after writing a write-ahead log record on the driver. + /// + /// Set this to 'true' when you want to use S3 (or any file system that does not support flushing) for the metadata WAL on the driver. + /// + /// Default: `false` + @Since { version = "1.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.driver.writeAheadLog.closeFileAfterWrite`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.driver.writeAheadLog.closeFileAfterWrite`. +//documentation +//> Whether to close the file after writing a write-ahead log record on the driver. +//> +//> Set this to 'true' when you want to use S3 (or any file system that does not support flushing) for the metadata WAL on the driver. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Whether to close the file after writing a write-ahead log record on the receivers. + /// + /// Set this to 'true' when you want to use S3 (or any file system that does not support flushing) for the data WAL on the receivers. + /// + /// Default: `false` + @Since { version = "1.6.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.streaming.receiver.writeAheadLog.closeFileAfterWrite`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.streaming.receiver.writeAheadLog.closeFileAfterWrite`. +//documentation +//> Whether to close the file after writing a write-ahead log record on the receivers. +//> +//> Set this to 'true' when you want to use S3 (or any file system that does not support flushing) for the data WAL on the receivers. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Number of threads used by RBackend to handle RPC calls from SparkR package. + /// + /// Default: `2` + @Since { version = "1.4.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.r.numRBackendThreads`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.r.numRBackendThreads`. +//documentation +//> Number of threads used by RBackend to handle RPC calls from SparkR package. +//> +//> Default: `2` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Executable for executing R scripts in cluster modes for both driver and workers. + /// + /// Default: `"Rscript"` + @Since { version = "1.5.3" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.r.command`: String? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.r.command`. +//documentation +//> Executable for executing R scripts in cluster modes for both driver and workers. +//> +//> Default: `"Rscript"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Executable for executing R scripts in client modes for driver. + /// + /// Ignored in cluster modes. + /// + /// Default: `spark.r.command` + @Since { version = "1.5.3" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.r.driver.command`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.r.driver.command`. +//documentation +//> Executable for executing R scripts in client modes for driver. +//> +//> Ignored in cluster modes. +//> +//> Default: `spark.r.command` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Executable for executing sparkR shell in client modes for driver. + /// + /// Ignored in cluster modes. + /// It is the same as environment variable `SPARKR_DRIVER_R`, but take precedence over it. `spark.r.shell.command` is used for sparkR shell while `spark.r.driver.command` is used for running R script. + /// + /// Default: `"R"` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.r.shell.command`: String? +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.r.shell.command`. +//documentation +//> Executable for executing sparkR shell in client modes for driver. +//> +//> Ignored in cluster modes. +//> It is the same as environment variable `SPARKR_DRIVER_R`, but take precedence over it. `spark.r.shell.command` is used for sparkR shell while `spark.r.driver.command` is used for running R script. +//> +//> Default: `"R"` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Connection timeout set by R process on its connection to RBackend in seconds. + /// + /// Default: `6000` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.r.backendConnectionTimeout`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.r.backendConnectionTimeout`. +//documentation +//> Connection timeout set by R process on its connection to RBackend in seconds. +//> +//> Default: `6000` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Interval for heartbeats sent from SparkR backend to R process to prevent connection timeout. + /// + /// Default: `100` + @Since { version = "2.1.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.r.heartBeatInterval`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.r.heartBeatInterval`. +//documentation +//> Interval for heartbeats sent from SparkR backend to R process to prevent connection timeout. +//> +//> Default: `100` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Checkpoint interval for graph and message in Pregel. + /// + /// It used to avoid stackOverflowError due to long lineage chains after lots of iterations. + /// The checkpoint is disabled by default. + /// + /// Default: `-1` + @Since { version = "2.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.graphx.pregel.checkpointInterval`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.graphx.pregel.checkpointInterval`. +//documentation +//> Checkpoint interval for graph and message in Pregel. +//> +//> It used to avoid stackOverflowError due to long lineage chains after lots of iterations. +//> The checkpoint is disabled by default. +//> +//> Default: `-1` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// The recovery mode setting to recover submitted Spark jobs with cluster mode when it failed and relaunches. + /// + /// This is only applicable for cluster mode when running with Standalone or Mesos. + /// + /// Default: `null` + @Since { version = "0.8.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.deploy.recoveryMode`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.deploy.recoveryMode`. +//documentation +//> The recovery mode setting to recover submitted Spark jobs with cluster mode when it failed and relaunches. +//> +//> This is only applicable for cluster mode when running with Standalone or Mesos. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// When \`spark.deploy.recoveryMode\` is set to ZOOKEEPER, this configuration is used to set the zookeeper URL to connect to. + /// + /// Default: `null` + @Since { version = "0.8.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.deploy.zookeeper.url`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.deploy.zookeeper.url`. +//documentation +//> When \`spark.deploy.recoveryMode\` is set to ZOOKEEPER, this configuration is used to set the zookeeper URL to connect to. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// When \`spark.deploy.recoveryMode\` is set to ZOOKEEPER, this configuration is used to set the zookeeper directory to store recovery state. + /// + /// Default: `null` + @Since { version = "0.8.1" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.deploy.zookeeper.dir`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.deploy.zookeeper.dir`. +//documentation +//> When \`spark.deploy.recoveryMode\` is set to ZOOKEEPER, this configuration is used to set the zookeeper directory to store recovery state. +//> +//> Default: `null` +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Class name of the implementation of `MergedShuffleFileManager` that manages push-based shuffle. + /// + /// This acts as a server side config to disable or enable push-based shuffle. + /// By default, push-based shuffle is disabled at the server side. + /// + /// + /// To enable push-based shuffle on the server side, set this config to `org.apache.spark.network.shuffle.RemoteBlockPushResolver` + /// + /// Default: org.apache.spark.network.shuffle.NoOpMergedShuffleFileManager + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.server.mergedShuffleFileManagerImpl`: String? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.server.mergedShuffleFileManagerImpl`. +//documentation +//> Class name of the implementation of `MergedShuffleFileManager` that manages push-based shuffle. +//> +//> This acts as a server side config to disable or enable push-based shuffle. +//> By default, push-based shuffle is disabled at the server side. +//> +//> +//> To enable push-based shuffle on the server side, set this config to `org.apache.spark.network.shuffle.RemoteBlockPushResolver` +//> +//> Default: org.apache.spark.network.shuffle.NoOpMergedShuffleFileManager +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The minimum size of a chunk when dividing a merged shuffle file into multiple chunks during push-based shuffle. + /// + /// A merged shuffle file consists of multiple small shuffle blocks. + /// Fetching the complete merged shuffle file in a single disk I/O increases the memory requirements for both the clients and the external shuffle services. + /// Instead, the external shuffle service serves the merged file in `MB-sized chunks`. + /// + /// This configuration controls how big a chunk can get. + /// A corresponding index file for each merged shuffle file will be generated indicating chunk boundaries. + /// + /// + /// Setting this too high would increase the memory requirements on both the clients and the external shuffle service. + /// + /// + /// Setting this too low would increase the overall number of RPC requests to external shuffle service unnecessarily. + /// + /// Default: `2.mib` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.server.minChunkSizeInMergedShuffleFile`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.server.minChunkSizeInMergedShuffleFile`. +//documentation +//> The minimum size of a chunk when dividing a merged shuffle file into multiple chunks during push-based shuffle. +//> +//> A merged shuffle file consists of multiple small shuffle blocks. +//> Fetching the complete merged shuffle file in a single disk I/O increases the memory requirements for both the clients and the external shuffle services. +//> Instead, the external shuffle service serves the merged file in `MB-sized chunks`. +//> +//> This configuration controls how big a chunk can get. +//> A corresponding index file for each merged shuffle file will be generated indicating chunk boundaries. +//> +//> +//> Setting this too high would increase the memory requirements on both the clients and the external shuffle service. +//> +//> +//> Setting this too low would increase the overall number of RPC requests to external shuffle service unnecessarily. +//> +//> Default: `2.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// The maximum size of cache in memory which could be used in push-based shuffle for storing merged index files. + /// + /// This cache is in addition to the one configured via `spark.shuffle.service.index.cache.size`. + /// + /// Default: `100.mib` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.server.mergedIndexCacheSize`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.server.mergedIndexCacheSize`. +//documentation +//> The maximum size of cache in memory which could be used in push-based shuffle for storing merged index files. +//> +//> This cache is in addition to the one configured via `spark.shuffle.service.index.cache.size`. +//> +//> Default: `100.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Set to true to enable push-based shuffle on the client side and works in conjunction with the server side flag `spark.shuffle.push.server.mergedShuffleFileManagerImpl`. + /// + /// Default: `false` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.enabled`: Boolean? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.enabled`. +//documentation +//> Set to true to enable push-based shuffle on the client side and works in conjunction with the server side flag `spark.shuffle.push.server.mergedShuffleFileManagerImpl`. +//> +//> Default: `false` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The amount of time driver waits in seconds, after all mappers have finished for a given shuffle map stage, before it sends merge finalize requests to remote external shuffle services. + /// + /// This gives the external shuffle services extra time to merge blocks. + /// Setting this too long could potentially lead to performance regression. + /// + /// Default: `10.s` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.finalize.timeout`: Duration? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.finalize.timeout`. +//documentation +//> The amount of time driver waits in seconds, after all mappers have finished for a given shuffle map stage, before it sends merge finalize requests to remote external shuffle services. +//> +//> This gives the external shuffle services extra time to merge blocks. +//> Setting this too long could potentially lead to performance regression. +//> +//> Default: `10.s` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + + /// Maximum number of merger locations cached for push-based shuffle. + /// + /// Currently, merger locations are hosts of external shuffle services responsible for handling pushed blocks, merging them and serving merged blocks for later shuffle fetch. + /// + /// Default: `500` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.maxRetainedMergerLocations`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.maxRetainedMergerLocations`. +//documentation +//> Maximum number of merger locations cached for push-based shuffle. +//> +//> Currently, merger locations are hosts of external shuffle services responsible for handling pushed blocks, merging them and serving merged blocks for later shuffle fetch. +//> +//> Default: `500` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Ratio used to compute the minimum number of shuffle merger locations required for a stage based on the number of partitions for the reducer stage. + /// + /// For example, a reduce stage which has 100 partitions and uses the default value 0.05 requires at least 5 unique merger locations to enable push-based shuffle. + /// + /// Default: `0.05` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.mergersMinThresholdRatio`: Float? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.mergersMinThresholdRatio`. +//documentation +//> Ratio used to compute the minimum number of shuffle merger locations required for a stage based on the number of partitions for the reducer stage. +//> +//> For example, a reduce stage which has 100 partitions and uses the default value 0.05 requires at least 5 unique merger locations to enable push-based shuffle. +//> +//> Default: `0.05` +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + + /// The static threshold for number of shuffle push merger locations should be available in order to enable push-based shuffle for a stage. + /// + /// Note this config works in conjunction with `spark.shuffle.push.mergersMinThresholdRatio`. + /// Maximum of `spark.shuffle.push.mergersMinStaticThreshold` and `spark.shuffle.push.mergersMinThresholdRatio` ratio number of mergers needed to enable push-based shuffle for a stage. + /// For example: with 1000 partitions for the child stage with spark.shuffle.push.mergersMinStaticThreshold as 5 and spark.shuffle.push.mergersMinThresholdRatio set to 0.05, we would need at least 50 mergers to enable push-based shuffle for that stage. + /// + /// Default: `5` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.mergersMinStaticThreshold`: Int? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.mergersMinStaticThreshold`. +//documentation +//> The static threshold for number of shuffle push merger locations should be available in order to enable push-based shuffle for a stage. +//> +//> Note this config works in conjunction with `spark.shuffle.push.mergersMinThresholdRatio`. +//> Maximum of `spark.shuffle.push.mergersMinStaticThreshold` and `spark.shuffle.push.mergersMinThresholdRatio` ratio number of mergers needed to enable push-based shuffle for a stage. +//> For example: with 1000 partitions for the child stage with spark.shuffle.push.mergersMinStaticThreshold as 5 and spark.shuffle.push.mergersMinThresholdRatio set to 0.05, we would need at least 50 mergers to enable push-based shuffle for that stage. +//> +//> Default: `5` +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// The max size of an individual block to push to the remote external shuffle services. + /// + /// Blocks larger than this threshold are not pushed to be merged remotely. + /// These shuffle blocks will be fetched in the original manner. + /// + /// + /// Setting this too high would result in more blocks to be pushed to remote external shuffle services but those are already efficiently fetched with the existing mechanisms resulting in additional overhead of pushing the large blocks to remote external shuffle services. + /// It is recommended to set `spark.shuffle.push.maxBlockSizeToPush` lesser than `spark.shuffle.push.maxBlockBatchSize` config's value. + /// + /// + /// Setting this too low would result in lesser number of blocks getting merged and directly fetched from mapper external shuffle service results in higher small random reads affecting overall disk I/O performance. + /// + /// Default: `1.mib` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.maxBlockSizeToPush`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.maxBlockSizeToPush`. +//documentation +//> The max size of an individual block to push to the remote external shuffle services. +//> +//> Blocks larger than this threshold are not pushed to be merged remotely. +//> These shuffle blocks will be fetched in the original manner. +//> +//> +//> Setting this too high would result in more blocks to be pushed to remote external shuffle services but those are already efficiently fetched with the existing mechanisms resulting in additional overhead of pushing the large blocks to remote external shuffle services. +//> It is recommended to set `spark.shuffle.push.maxBlockSizeToPush` lesser than `spark.shuffle.push.maxBlockBatchSize` config's value. +//> +//> +//> Setting this too low would result in lesser number of blocks getting merged and directly fetched from mapper external shuffle service results in higher small random reads affecting overall disk I/O performance. +//> +//> Default: `1.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// The max size of a batch of shuffle blocks to be grouped into a single push request. + /// + /// Default is set to `3m` in order to keep it slightly higher than `spark.storage.memoryMapThreshold` default which is `2m` as it is very likely that each batch of block gets memory mapped which incurs higher overhead. + /// + /// Default: `3.mib` + @Since { version = "3.2.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.maxBlockBatchSize`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.maxBlockBatchSize`. +//documentation +//> The max size of a batch of shuffle blocks to be grouped into a single push request. +//> +//> Default is set to `3m` in order to keep it slightly higher than `spark.storage.memoryMapThreshold` default which is `2m` as it is very likely that each batch of block gets memory mapped which incurs higher overhead. +//> +//> Default: `3.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Driver will wait for merge finalization to complete only if total shuffle data size is more than this threshold. + /// + /// If total shuffle size is less, driver will immediately finalize the shuffle output. + /// + /// Default: `500.mib` + @Since { version = "3.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.minShuffleSizeToWait`: DataSize? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.minShuffleSizeToWait`. +//documentation +//> Driver will wait for merge finalization to complete only if total shuffle data size is more than this threshold. +//> +//> If total shuffle size is less, driver will immediately finalize the shuffle output. +//> +//> Default: `500.mib` +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// Fraction of minimum map partitions that should be push complete before driver starts shuffle merge finalization during push based shuffle. + /// + /// Default: `1.0` + @Since { version = "3.3.0" } +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Since# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/version. + `spark.shuffle.push.minCompletedPushRatio`: Float? +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/`spark.shuffle.push.minCompletedPushRatio`. +//documentation +//> Fraction of minimum map partitions that should be push complete before driver starts shuffle merge finalization during push based shuffle. +//> +//> Default: `1.0` +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + + typealias ResourceName = String +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `Properties.pkl`/ResourceName# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + diff --git a/pkl-pantrysnapshot/org.apache.spark/PropertiesBase.pkl b/pkl-pantrysnapshot/org.apache.spark/PropertiesBase.pkl new file mode 100755 index 00000000..ecca1e37 --- /dev/null +++ b/pkl-pantrysnapshot/org.apache.spark/PropertiesBase.pkl @@ -0,0 +1,83 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + abstract module org.apache.spark.PropertiesBase +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/ + + import "pkl:semver" + import "utils.pkl" + + /// The Spark version to use these properties with. + hidden targetSparkVersion: String? +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/targetSparkVersion. +// documentation +// > The Spark version to use these properties with. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + function since(sparkVersion: String): Boolean = +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/since(). +// ^^^^^^^^^^^^ definition local sparkVersion_24 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + if (targetSparkVersion == null) true +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/targetSparkVersion. + else + let (parsedVersion = semver.Version(sparkVersion)) +// ^^^^^^^^^^^^^ definition local parsedVersion_27 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.semver`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.semver`/Version(). +// ^^^^^^^^^^^^ reference local sparkVersion_24 + if (!parsedVersion.isGreaterThan(semver.Version(targetSparkVersion))) +// ^^^^^^^^^^^^^ reference local parsedVersion_27 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.semver`/Version#isGreaterThan(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.semver`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.semver`/Version(). +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/targetSparkVersion. + throw("This property exists since Spark version \(parsedVersion), but target Spark version is \(targetSparkVersion).") +// ^^^^^^^^^^^^^ reference local parsedVersion_27 +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/targetSparkVersion. + else + true + + hidden effectiveProperties: Map = +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/effectiveProperties. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# + module.toMap().flatMap((key, value) -> utils.convertProperty(key, value)) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#flatMap(). +// ^^^ definition local key_34 +// ^^^^^ definition local value_34 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertProperty(). +// ^^^ reference local key_34 +// ^^^^^ reference local value_34 + + /// Indicates that the annotated property cannot be set by the user. + class Reserved extends Annotation +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/Reserved# +// documentation +// > Indicates that the annotated property cannot be set by the user. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Annotation# + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/output. + value = effectiveProperties +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/value. +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/effectiveProperties. + renderer = new PropertiesRenderer {} +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/renderer. +// ^^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PropertiesRenderer# + } + diff --git a/pkl-pantrysnapshot/org.apache.spark/tests/PropertiesBase.pkl b/pkl-pantrysnapshot/org.apache.spark/tests/PropertiesBase.pkl new file mode 100755 index 00000000..4ad2e55a --- /dev/null +++ b/pkl-pantrysnapshot/org.apache.spark/tests/PropertiesBase.pkl @@ -0,0 +1,79 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.apache.spark.tests.PropertiesBase +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/ + + amends "pkl:test" + + import "../PropertiesBase.pkl" + + local class SampleSparkProperties extends PropertiesBase { +// ^^^^^^^^^^^^^^^^^^^^^ definition local SampleSparkProperties_22 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `PropertiesBase.pkl`/ + `spark.core.numbers`: Int? +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/SampleSparkProperties#`spark.core.numbers`. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + `spark.{driver|executor}.something`: Mapping? +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/SampleSparkProperties#`spark.{driver|executor}.something`. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + `spark.shards.[0-9].setting.[node].memory`: Mapping>? +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/SampleSparkProperties#`spark.shards.[0-9].setting.[node].memory`. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + `spark.kubernetes.some.type.of.memory`: DataSize? +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/SampleSparkProperties#`spark.kubernetes.some.type.of.memory`. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + `spark.some.type.of.duration`: Duration? +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/SampleSparkProperties#`spark.some.type.of.duration`. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + } + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/examples. + ["rendering properties"] { + new SampleSparkProperties { +// ^^^^^^^^^^^^^^^^^^^^^ reference local SampleSparkProperties_22 + `spark.{driver|executor}.something` { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/`spark.{driver|executor}.something`. + ["driver"] = "some driver setting" + ["executor"] = "some executor setting" + } + `spark.core.numbers` = 5 +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/`spark.core.numbers`. + `spark.shards.[0-9].setting.[node].memory` { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/`spark.shards.[0-9].setting.[node].memory`. + ["1"] { + ["this-node"] = 5.gib +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#gib. + } + } + `spark.kubernetes.some.type.of.memory` = 10.gib +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/`spark.kubernetes.some.type.of.memory`. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#gib. + `spark.some.type.of.duration` = 5.min +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/PropertiesBase.pkl`/`spark.some.type.of.duration`. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#min. + }.output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + diff --git a/pkl-pantrysnapshot/org.apache.spark/tests/utils.pkl b/pkl-pantrysnapshot/org.apache.spark/tests/utils.pkl new file mode 100755 index 00000000..adfa86a7 --- /dev/null +++ b/pkl-pantrysnapshot/org.apache.spark/tests/utils.pkl @@ -0,0 +1,88 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.apache.spark.tests.utils +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/utils.pkl`/ + + amends "pkl:test" + + import "../utils.pkl" + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `tests/utils.pkl`/examples. + ["convertIndexedProperty"] { + utils.convertIndexedProperty("foo.bar.[baz].biz.[buz]", new Mapping { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertIndexedProperty(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["1"] = new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["11"] = "eleven" + ["12"] = "twelve" + } + ["2"] = new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["22"] = "two" + } + }) + utils.convertIndexedProperty("foo.bar.[baz].biz", new Mapping { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertIndexedProperty(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["1"] = 1 + ["2"] = 2 + }) + } + ["flattenMapKeys"] { + utils.flattenMapKeys(new Mapping { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/ +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/flattenMapKeys(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["1"] = new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["11"] = "eleven" + ["12"] = "twelve" + } + ["2"] = new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["22"] = "two" + } + }, List()) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + } + ["convertProperty"] { + utils.convertProperty("foo.bar.baz", 1) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertProperty(). + utils.convertProperty("foo.env.[baz]", new Mapping { ["FOO"] = "foo"; ["BAR"] = "bar" }) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertProperty(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + utils.convertProperty("foo.env.[baz].buz.{baz}", new Mapping { ["FOO"] = new Mapping { ["BAR"] = "bar" } }) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertProperty(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + utils.convertProperty("spark.kubernetes.baz", 5.gib) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertProperty(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#gib. + utils.convertProperty("spark.memory", 5.gib) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertProperty(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#gib. + } + } + diff --git a/pkl-pantrysnapshot/org.apache.spark/utils.pkl b/pkl-pantrysnapshot/org.apache.spark/utils.pkl new file mode 100755 index 00000000..53f55309 --- /dev/null +++ b/pkl-pantrysnapshot/org.apache.spark/utils.pkl @@ -0,0 +1,271 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.apache.spark.utils +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/ + + /// Match indexed positions in a property. + /// + /// For example matches `.[0-9]` or `.[Foo]` or `.{Foo}` + // language=regexp + indexRegex: Regex = Regex(#""" +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/indexRegex. +//documentation +//> Match indexed positions in a property. +//> +//> For example matches `.`0-9`` or `.`Foo`` or `.{Foo}` +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + (?x) # turn on extended mode + \. # '.' literal + (?: + \{ # '{' literal + ([^}]+) # capture: any character except for '}' + } # followed by '}' + | # OR + \[ # '[' literal + ([^]]+) # capture: any character except for ']' + ] # folowed by ']' + ) + """#) + + // https://spark.apache.org/docs/latest/configuration.html#spark-properties + function convertDuration(dur: Duration): String = +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertDuration(). +// ^^^ definition local dur_37 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (dur.unit == "ns" || dur.unit == "us") convertDuration(dur.toUnit("ms")) +// ^^^ reference local dur_37 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#unit. +// ^^^ reference local dur_37 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#unit. +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertDuration(). +// ^^^ reference local dur_37 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#toUnit(). + else "\(dur.value)\(dur.unit)" +// ^^^ reference local dur_37 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#value. +// ^^^ reference local dur_37 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#unit. + + function convertValue(propName: String, propValue: Any): Any = +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertValue(). +// ^^^^^^^^ definition local propName_41 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ definition local propValue_41 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + if (propValue is Duration) +// ^^^^^^^^^ reference local propValue_41 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + convertDuration(propValue) +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertDuration(). +// ^^^^^^^^^ reference local propValue_41 + else if (propValue is DataSize) +// ^^^^^^^^^ reference local propValue_41 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + if (propName.contains(".kubernetes.")) +// ^^^^^^^^ reference local propName_41 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + // taken from io.k8s.K8sObject + let (unit = propValue.unit) +// ^^^^ definition local unit_47 +// ^^^^^^^^^ reference local propValue_41 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize#unit. + let (k8sUnit = +// ^^^^^^^ definition local k8sUnit_48 + if (unit.length == 3) unit[0].toUpperCase() + unit[1] +// ^^^^ reference local unit_47 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^ reference local unit_47 +// ^^^^ reference local unit_47 + else if (unit.length == 2) unit[0].toUpperCase() +// ^^^^ reference local unit_47 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^ reference local unit_47 + else "" + ) + "\(propValue.value)\(k8sUnit)" +// ^^^^^^^^^ reference local propValue_41 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize#value. +// ^^^^^^^ reference local k8sUnit_48 + else + // https://spark.apache.org/docs/latest/configuration.html#spark-properties + let (bin = propValue.toBinaryUnit()) "\(bin.value)\(bin.unit.take(1))" +// ^^^ definition local bin_56 +// ^^^^^^^^^ reference local propValue_41 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize#toBinaryUnit(). +// ^^^ reference local bin_56 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize#value. +// ^^^ reference local bin_56 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize#unit. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#take(). + else propValue +// ^^^^^^^^^ reference local propValue_41 + + /// Converts a property to its expanded set of properties. + function convertProperty(propName: String, propValue: Any): Map = +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertProperty(). +// documentation +// > Converts a property to its expanded set of properties. +// ^^^^^^^^ definition local propName_60 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ definition local propValue_60 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# + if (propValue is Mapping) +// ^^^^^^^^^ reference local propValue_60 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + convertIndexedProperty(propName, propValue) +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertIndexedProperty(). +// ^^^^^^^^ reference local propName_60 +// ^^^^^^^^^ reference local propValue_60 + else + Map(propName, convertValue(propName, propValue)) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^^^ reference local propName_60 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertValue(). +// ^^^^^^^^ reference local propName_60 +// ^^^^^^^^^ reference local propValue_60 + + /// Flatten a deeply nested Mapping into a Map where the keys becomes a list + /// + /// For example: + /// + /// new Mapping { ["foo"] = new Mapping { ["bar"] = 100 } } + /// + /// Becomes: + /// + /// Map(List(".foo", ".bar"), 100) + /// + function flattenMapKeys(value: Mapping, path: List): Map, unknown> = +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/flattenMapKeys(). +// documentation +// > Flatten a deeply nested Mapping into a Map where the keys becomes a list +// > +// > For example: +// > +// > new Mapping { `"foo"` = new Mapping { `"bar"` = 100 } } +// > +// > Becomes: +// > +// > Map(List(".foo", ".bar"), 100) +// ^^^^^ definition local value_76 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ definition local path_76 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + value +// ^^^^^ reference local value_76 + .toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + .flatMap((key, _value) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#flatMap(). +// ^^^ definition local key_79 +// ^^^^^^ definition local _value_79 + if (_value is Mapping) flattenMapKeys(_value, path.add("." + key)) +// ^^^^^^ reference local _value_79 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/flattenMapKeys(). +// ^^^^^^ reference local _value_79 +// ^^^^ reference local path_76 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local key_79 + else Map(path.add("." + key), _value) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^ reference local path_76 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local key_79 +// ^^^^^^ reference local _value_79 + ) + + /// Performs substituting of indexed positions with the corresponding Mapping keys. + /// + /// Given prop `foo.bar.[baz].biz.[buz]` and value `new { [1] { [11] = "one" }; [2] { [22] = "two" } }`, + /// produces: + /// + /// Map( + /// "foo.bar.1.biz.11", "one", + /// "foo.bar.2.biz.22", "two" + /// ) + function convertIndexedProperty(propName: String, propValue: Mapping): Map = +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertIndexedProperty(). +// documentation +// > Performs substituting of indexed positions with the corresponding Mapping keys. +// > +// > Given prop `foo.bar.`baz`.biz.`buz`` and value `new { `1` { `11` = "one" }; `2` { `22` = "two" } }`, +// > produces: +// > +// > Map( +// > "foo.bar.1.biz.11", "one", +// > "foo.bar.2.biz.22", "two" +// > ) +// ^^^^^^^^ definition local propName_93 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ definition local propValue_93 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# + let (propNameParts = propName.split(indexRegex)) +// ^^^^^^^^^^^^^ definition local propNameParts_94 +// ^^^^^^^^ reference local propName_93 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/indexRegex. + let (flattenedMap = flattenMapKeys(propValue, List())) +// ^^^^^^^^^^^^ definition local flattenedMap_95 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/flattenMapKeys(). +// ^^^^^^^^^ reference local propValue_93 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + flattenedMap.map((key, value) -> +// ^^^^^^^^^^^^ reference local flattenedMap_95 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#map(). +// ^^^ definition local key_96 +// ^^^^^ definition local value_96 + let (convertedProperty = propNameParts +// ^^^^^^^^^^^^^^^^^ definition local convertedProperty_97 +// ^^^^^^^^^^^^^ reference local propNameParts_94 + .zip(key) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#zip(). +// ^^^ reference local key_96 + .flatMap((pair) -> List(pair.first, pair.second)) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#flatMap(). +// ^^^^ definition local pair_99 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^ reference local pair_99 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^^^^ reference local pair_99 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + .join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + if (propNameParts.length > key.length) propNameParts.last else "" +// ^^^^^^^^^^^^^ reference local propNameParts_94 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^ reference local key_96 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^^^^^^^^^ reference local propNameParts_94 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + ) + Pair(convertedProperty, convertValue(convertedProperty, value)) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^^^^^^^^^^^^ reference local convertedProperty_97 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.apache.spark 1.0.2 `utils.pkl`/convertValue(). +// ^^^^^^^^^^^^^^^^^ reference local convertedProperty_97 +// ^^^^^ reference local value_96 + ) + diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/PklProject b/pkl-pantrysnapshot/org.json_schema.contrib/PklProject new file mode 100755 index 00000000..3f8935b1 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/PklProject @@ -0,0 +1,33 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Utilities for [JSON Schema](https://json-schema.org). + /// + /// This package includes utilities for generating Pkl from a given JSON Schema document. + amends "../basePklProject.pkl" + + dependencies { +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 PklProject/dependencies. + ["jsonschema"] = import("../org.json_schema/PklProject") + ["uri"] = import("../pkl.experimental.uri/PklProject") + ["syntax"] = import("../pkl.experimental.syntax/PklProject") + } + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 PklProject/package. + version = "1.1.5" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/generate.pkl b/pkl-pantrysnapshot/org.json_schema.contrib/generate.pkl new file mode 100755 index 00000000..e76acd85 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/generate.pkl @@ -0,0 +1,150 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Generate Pkl sources from JSON Schema documents. + /// + /// Limitations: + /// - Cannot generate `not`, `allOf`, or `anyOf` combinators correctly due to limitations in Pkl's model. + /// * Union types exist, but they are logically the same as `oneOf` (only one subschema can match). + /// * Intersection types do not exist (can use this to model `allOf`). + /// - Doesn't generate correct types for schemas that use both [JsonSchema.properties] and + /// [JsonSchema.additionalProperties] because classes cannot contain entries + /// (known limitation, will be addressed in a future Pkl release). Some possible workarounds: + /// * Add a child Mapping property to represent "additional properties" and add a renderer to inline them/ + /// * Add an option to the generator to control whether a class or a Mapping gets generated. + /// - Cannot generate [JsonSchema.patternProperties] fully (this is a limitation of Pkl). + /// If there is just one pattern property, it gets generated as a [Mapping]. + /// Otherwise, this falls back to [Dynamic], which is the loosest constraint. + /// - Cannot generate tuple types (this is missing in Pkl). + /// - Properties called `default` cannot be generated (currently a limitation of the json parser). + /// - `allOf` schemas have several limitations + /// * `default` will only be combined when all subschemas have the same value + /// * `deprecated` will be [true] if an only if all subschemas have it set to [true], otherwise it will be null + /// * `readOnly` and `writeOnly` must be identical for all subschemas + /// * `type` must be identical (or null) for all subschemas + /// * `const` must be identical (or null) for all subschemas + /// * if multiple subschemas set `multipleOf`, all must be integers + /// * `format` must be identical (or null) for all subschemas + /// * overlapping `properties` and `patternProperties` entries are merged as `allOf` according to these rules + /// * fields that accept [JsonSchema.Schema] values must all be [JsonSchema] values (or null) + /// * `items` must be [JsonSchema] or null, not [Listing]<[JsonSchema]> + /// * there must be precise overlap between elements of `oneOf` and `anyOf` + /// + /// TODO: + /// - Copy doc comments from a class or typealias to its usage sites if there isn't a doc comment already. + /// - Handle if schema root is not an object type (Example: ansible's schema root has `"type": "array"`). + /// - Handle if schema root should be a mapping (it has `additionalProperties` or `patternProperties` set). + /// + /// Sample CLI usage: + /// + /// ``` + /// pkl eval package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib@#/generate.pkl \ + /// -m . \ + /// -p source="https://json.schemastore.org/github-action.json" + /// ``` + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `generate.pkl`/minPklVersion. + module org.json_schema.contrib.generate +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `generate.pkl`/ + + import "pkl:platform" + + import "@jsonschema/Parser.pkl" + import "@jsonschema/JsonSchema.pkl" + import "@uri/URI.pkl" + import "internal/ModulesGenerator.pkl" + + local sourceProperty = read("prop:source") +// ^^^^^^^^^^^^^^ definition local sourceProperty_67 + local sourceUri = +// ^^^^^^^^^ definition local sourceUri_68 + if (sourceProperty.startsWith(Regex(#"\w+:"#))) sourceProperty // absolute URI +// ^^^^^^^^^^^^^^ reference local sourceProperty_67 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^^^^^^ reference local sourceProperty_67 + else if (sourceProperty.startsWith("/")) "file://\(sourceProperty)" // absolute file path +// ^^^^^^^^^^^^^^ reference local sourceProperty_67 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^^^^^^^^^^ reference local sourceProperty_67 + else // relative file path + let (pwd = read("env:PWD")) +// ^^^ definition local pwd_72 + let (path = +// ^^^^ definition local path_73 + if (platform.current.operatingSystem.name == "Windows") "/\(pwd)/\(sourceProperty)".replaceAll("\\", "/") +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/current. +// ^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/Platform#operatingSystem. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.platform`/OperatingSystem#name. +// ^^^ reference local pwd_72 +// ^^^^^^^^^^^^^^ reference local sourceProperty_67 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + else "\(pwd)/\(sourceProperty)" +// ^^^ reference local pwd_72 +// ^^^^^^^^^^^^^^ reference local sourceProperty_67 + ) + "file://\(URI.encode(path))" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^ reference local path_73 + + local schema = read(URI.encode(sourceUri)) +// ^^^^^^ definition local schema_79 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^^^^^^ reference local sourceUri_68 + + local parsedJsonSchema = Parser.parse(schema) +// ^^^^^^^^^^^^^^^^ definition local parsedJsonSchema_81 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/parse(). +// ^^^^^^ reference local schema_79 + + local modulesGenerator = new ModulesGenerator { +// ^^^^^^^^^^^^^^^^ definition local modulesGenerator_83 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/ + rootSchema = parsedJsonSchema as JsonSchema +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `generate.pkl`/rootSchema. +// ^^^^^^^^^^^^^^^^ reference local parsedJsonSchema_81 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + baseUri = URI.parse(sourceUri)!! +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `generate.pkl`/baseUri. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^^^ reference local sourceUri_68 + } + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `generate.pkl`/output. + text = throw("The JSON Schema generator only works with multiple-file output. Try running again with the -m option.") +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `generate.pkl`/text. + files { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `generate.pkl`/files. + for (mod in modulesGenerator.modules) { +// ^^^ definition local mod_91 +// ^^^^^^^^^^^^^^^^ reference local modulesGenerator_83 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/modules. + ["\(mod.moduleName).pkl"] = mod.moduleNode.output +// ^^^ reference local mod_91 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleName. +// ^^^ reference local mod_91 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. + } + } + } + diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/internal/ModuleGenerator.pkl b/pkl-pantrysnapshot/org.json_schema.contrib/internal/ModuleGenerator.pkl new file mode 100755 index 00000000..43499ef6 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/internal/ModuleGenerator.pkl @@ -0,0 +1,874 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Support for generating classes. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/minPklVersion. + @Unlisted +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Unlisted# + module org.json_schema.contrib.internal.ModuleGenerator +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ + + import "@syntax/TypeNode.pkl" + import "@syntax/ClassNode.pkl" + import "@syntax/ClassOrModuleNode.pkl" + import "@syntax/TypeAliasNode.pkl" + import "@syntax/ModuleNode.pkl" + import "@syntax/DocCommentNode.pkl" + import "@jsonschema/JsonSchema.pkl" + import "@uri/URI.pkl" + import "utils.pkl" + import "TypesGenerator.pkl" + import "../ref.pkl" + import "Type.pkl" + import "singularize.pkl" + + local pcfRenderer = new PcfRenderer { useCustomStringDelimiters = true } +// ^^^^^^^^^^^ definition local pcfRenderer_35 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer# +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/useCustomStringDelimiters. + local jsonRenderer = new JsonRenderer {} +// ^^^^^^^^^^^^ definition local jsonRenderer_36 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer# + + /// The root schema, used to resolve `$ref` values. + rootSchema: JsonSchema +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/rootSchema. +//documentation +//> The root schema, used to resolve `$ref` values. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + + // local collatedRootSchema = rootSchema + local collatedRootSchema = if (rootSchema.allOf != null) TypesGenerator.collateAllOf(rootSchema) else rootSchema +// ^^^^^^^^^^^^^^^^^^ definition local collatedRootSchema_42 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/rootSchema. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/allOf. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/collateAllOf(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/rootSchema. + + /// The URI representing the root schema, used to resolve `$ref` values. + baseUri: URI +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/baseUri. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + + /// Existing type names that have been generated prior to generating this module. + existingTypes: Type.TypeNames +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/existingTypes. +//documentation +//> Existing type names that have been generated prior to generating this module. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# + + /// The name of this module + moduleName: String = utils.pascalCase(baseUri.pathSegments.last.replaceAll(".json", "")) +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleName. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/pascalCase(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/baseUri. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + + local typesGenerator: TypesGenerator = new { baseUri = module.baseUri; enclosingModuleName = moduleName } +// ^^^^^^^^^^^^^^ definition local typesGenerator_53 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/baseUri. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/baseUri. +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/enclosingModuleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleName. + + /// The types described directly in this JSON Schema document (excludes types in an external reference). + moduleTypes: Type.TypeNames = typeAliasSchemas + classSchemas +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleTypes. +//documentation +//> The types described directly in this JSON Schema document (excludes types in an external reference). +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^^^^^^^^^^^^^^ reference local typeAliasSchemas_293 +// ^^^^^^^^^^^^ reference local classSchemas_269 + + /// Generate a Pkl [ModuleNode] from a given schema. + moduleNode: ModuleNode = +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +//documentation +//> Generate a Pkl [`ModuleNode`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.syntax/ModuleNode.pkl#L18,C1) from a given schema. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ + let (allTypeNames = moduleTypes + existingTypes) +// ^^^^^^^^^^^^ definition local allTypeNames_60 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleTypes. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/existingTypes. + new { + imports { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/imports. + for (moduleName in existingTypes.values.map((it) -> it.moduleName).toSet()) { +// ^^^^^^^^^^ definition local moduleName_63 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/existingTypes. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local it_63 +// ^^ reference local it_63 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/moduleName. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toSet(). + new { + // TODO: shouldn't include transitive deps + value = "\(moduleName.split(".").last).pkl" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/value. +// ^^^^^^^^^^ reference local moduleName_63 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + } + } + } + classes { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/classes. + for (schema, type in classSchemas) { +// ^^^^^^ definition local schema_71 +// ^^^^ definition local type_71 +// ^^^^^^^^^^^^ reference local classSchemas_269 + generatePklClass(schema, type, allTypeNames) +// ^^^^^^^^^^^^^^^^ reference local generatePklClass_174 +// ^^^^^^ reference local schema_71 +// ^^^^ reference local type_71 +// ^^^^^^^^^^^^ reference local allTypeNames_60 + } + } + typealiases { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/typealiases. + for (schema, type in typeAliasSchemas) { +// ^^^^^^ definition local schema_76 +// ^^^^ definition local type_76 +// ^^^^^^^^^^^^^^^^ reference local typeAliasSchemas_293 + generatePklTypeAlias(schema, type, allTypeNames) +// ^^^^^^^^^^^^^^^^^^^^ reference local generatePklTypeAlias_189 +// ^^^^^^ reference local schema_76 +// ^^^^ reference local type_76 +// ^^^^^^^^^^^^ reference local allTypeNames_60 + } + } + declaration { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/declaration. + docComment = getDocComment(collatedRootSchema, "module") +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/docComment. +// ^^^^^^^^^^^^^ reference local getDocComment_100 +// ^^^^^^^^^^^^^^^^^^ reference local collatedRootSchema_42 + when (moduleName != null) { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleName. + moduleHeader { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleHeader. + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/parts. + for (part in moduleName.split(".")) { +// ^^^^ definition local part_86 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleName. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). + new { value = part } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/value. +// ^^^^ reference local part_86 + } + } + } + } + } + } + properties = +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/properties. + if (isClassLike(collatedRootSchema)) +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/isClassLike(). +// ^^^^^^^^^^^^^^^^^^ reference local collatedRootSchema_42 + generateClassBody(collatedRootSchema, allTypeNames) +// ^^^^^^^^^^^^^^^^^ reference local generateClassBody_140 +// ^^^^^^^^^^^^^^^^^^ reference local collatedRootSchema_42 +// ^^^^^^^^^^^^ reference local allTypeNames_60 + else null + } + + /// Determine the doc comments of a schema. + /// + /// This combines a schema's title, description and "default" descriptions into one doc comment. + /// Wraps the comments at 100 columns. + local function getDocComment(schema: JsonSchema|Boolean, type: "class"|"module"|Null): DocCommentNode? = +// ^^^^^^^^^^^^^ definition local getDocComment_100 +// documentation +// > Determine the doc comments of a schema. +// > +// > This combines a schema's title, description and "default" descriptions into one doc comment. +// > Wraps the comments at 100 columns. +// ^^^^^^ definition local schema_104 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^ definition local type_104 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/ + if (schema is Boolean) +// ^^^^^^ reference local schema_104 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + null + else + let (docCommentText: String = +// ^^^^^^^^^^^^^^ definition local docCommentText_108 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + List( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + schema.title, +// ^^^^^^ reference local schema_104 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/title. + schema.description, +// ^^^^^^ reference local schema_104 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/description. + if (type is "module") "This module was generated from JSON Schema from <\(baseUri)>." else null, +// ^^^^ reference local type_104 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/baseUri. + if (type is "class"|"module") getWarnings(schema, type) else null, +// ^^^^ reference local type_104 +// ^^^^^^^^^^^ reference local getWarnings_125 +// ^^^^^^ reference local schema_104 +// ^^^^ reference local type_104 + if (schema.default != null) "Default if undefined: `\(pcfRenderer.renderValue(schema.default))`" else null +// ^^^^^^ reference local schema_104 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/default. +// ^^^^^^^^^^^ reference local pcfRenderer_35 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer#renderValue(). +// ^^^^^^ reference local schema_104 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/default. + ) + .filterNonNull() +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). + .join("\n\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + ) + if (docCommentText.isEmpty) null +// ^^^^^^^^^^^^^^ reference local docCommentText_108 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. + else new DocCommentNode { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/ + value = docCommentText +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/value. +// ^^^^^^^^^^^^^^ reference local docCommentText_108 + autoWrap = true +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/autoWrap. + } + + local function getWarnings(schema: JsonSchema, type: "class"|"module"): String? = +// ^^^^^^^^^^^ definition local getWarnings_125 +// ^^^^^^ definition local schema_125 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition local type_125 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (schema.properties != null && (schema.additionalProperties is JsonSchema || schema.patternProperties != null)) +// ^^^^^^ reference local schema_125 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. +// ^^^^^^ reference local schema_125 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^ reference local schema_125 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/patternProperties. + """ + WARN: both properties and at least one of additionalProperties and patternProperties are set. + This is ambiguously defined; can either be defined as a `Mapping` or a class. + """ + else if (type == "class") null +// ^^^^ reference local type_125 + else if (schema.type == "object" && schema.additionalProperties != false) +// ^^^^^^ reference local schema_125 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^ reference local schema_125 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. + "WARN: The root schema describes open-ended properties, but this is not possible to describe at the module level." + else if (schema.type != null && schema.type != "object") +// ^^^^^^ reference local schema_125 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^ reference local schema_125 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. + "WARN: The root schema's type is `\(jsonRenderer.renderValue(schema.type))`, and cannot be correctly mapped to a Pkl module." +// ^^^^^^^^^^^^ reference local jsonRenderer_36 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer#renderValue(). +// ^^^^^^ reference local schema_125 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. + else if (schema.properties == null) +// ^^^^^^ reference local schema_125 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + "WARN: unable to determine module-level properties on the root schema." + else null + + local function generateClassBody( +// ^^^^^^^^^^^^^^^^^ definition local generateClassBody_140 + schema: JsonSchema(this.properties != null), +// ^^^^^^ definition local schema_141 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + typeNames: Type.TypeNames +// ^^^^^^^^^ definition local typeNames_142 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# + ): Listing = +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode# + if (schema.$$refUri != null) +// ^^^^^^ reference local schema_141 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$refUri. + let (referencedSchema = ref.resolveRef(baseUri, schema)) +// ^^^^^^^^^^^^^^^^ definition local referencedSchema_145 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/resolveRef(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/baseUri. +// ^^^^^^ reference local schema_141 + if (referencedSchema == null) new {} +// ^^^^^^^^^^^^^^^^ reference local referencedSchema_145 + else if (referencedSchema is Boolean) let (_ = trace("WARN: `$ref` points to a boolean somehow")) new {} +// ^^^^^^^^^^^^^^^^ reference local referencedSchema_145 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + else generateClassBody(referencedSchema as JsonSchema, typeNames) +// ^^^^^^^^^^^^^^^^^ reference local generateClassBody_140 +// ^^^^^^^^^^^^^^^^ reference local referencedSchema_145 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ reference local typeNames_142 + else if (schema.allOf != null) generateClassBody(TypesGenerator.collateAllOf(schema), typeNames) +// ^^^^^^ reference local schema_141 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/allOf. +// ^^^^^^^^^^^^^^^^^ reference local generateClassBody_140 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/collateAllOf(). +// ^^^^^^ reference local schema_141 +// ^^^^^^^^^ reference local typeNames_142 + else + new { + for (propName, propSchema in schema.properties!!) { +// ^^^^^^^^ definition local propName_152 +// ^^^^^^^^^^ definition local propSchema_152 +// ^^^^^^ reference local schema_141 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + new { + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/name. + value = propName +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/value. +// ^^^^^^^^ reference local propName_152 + } + when (propSchema is JsonSchema && propSchema.deprecated == true) { +// ^^^^^^^^^^ reference local propSchema_152 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^ reference local propSchema_152 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/deprecated. + annotations { utils.DEPRECATED } +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/annotations. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/DEPRECATED. + } + docComment = getDocComment(propSchema, null) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/docComment. +// ^^^^^^^^^^^^^ reference local getDocComment_100 +// ^^^^^^^^^^ reference local propSchema_152 + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/typeAnnotation. + // If this property doesn't appear in the `required` array, mark it as nullable. + // We can't do this within [TypesGenerator] because it doesn't have enough information available. + type = let (underlyingType = typesGenerator.generateTypeNode(propSchema, typeNames)) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/type. +// ^^^^^^^^^^^^^^ definition local underlyingType_164 +// ^^^^^^^^^^^^^^ reference local typesGenerator_53 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference local propSchema_152 +// ^^^^^^^^^ reference local typeNames_142 + if (schema.required?.toSet()?.contains(propName) ?? false) underlyingType +// ^^^^^^ reference local schema_141 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/required. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toSet(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). +// ^^^^^^^^ reference local propName_152 +// ^^^^^^^^^^^^^^ reference local underlyingType_164 + // If the type is already nullable, no need to make it *more* nullable. + else if (underlyingType is TypeNode.NullableTypeNode) underlyingType +// ^^^^^^^^^^^^^^ reference local underlyingType_164 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode# +// ^^^^^^^^^^^^^^ reference local underlyingType_164 + else new TypeNode.NullableTypeNode { typeNode = underlyingType } +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/typeNode. +// ^^^^^^^^^^^^^^ reference local underlyingType_164 + } + } + } + } + + /// Generates a [ClassNode] from a [JsonSchema]. + local function generatePklClass(schema: JsonSchema, className: Type, typeNames: Type.TypeNames): ClassNode = +// ^^^^^^^^^^^^^^^^ definition local generatePklClass_174 +// documentation +// > Generates a [`ClassNode`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.syntax/ClassNode.pkl#L16,C1) from a [`JsonSchema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L22,C1). +// ^^^^^^ definition local schema_175 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ definition local className_175 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ +// ^^^^^^^^^ definition local typeNames_175 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ + new { + docComment = getDocComment(schema, "class") +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/docComment. +// ^^^^^^^^^^^^^ reference local getDocComment_100 +// ^^^^^^ reference local schema_175 + when (schema.deprecated == true) { +// ^^^^^^ reference local schema_175 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/deprecated. + annotations { utils.DEPRECATED } +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/annotations. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/DEPRECATED. + } + classHeader { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/classHeader. + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/name. + value = className.name +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/value. +// ^^^^^^^^^ reference local className_175 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/name. + } + } + properties = generateClassBody(schema, typeNames) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/properties. +// ^^^^^^^^^^^^^^^^^ reference local generateClassBody_140 +// ^^^^^^ reference local schema_175 +// ^^^^^^^^^ reference local typeNames_175 + } + + /// Generates a [TypeAliasNode] from a [JsonSchema]. + local function generatePklTypeAlias( +// ^^^^^^^^^^^^^^^^^^^^ definition local generatePklTypeAlias_189 +// documentation +// > Generates a [`TypeAliasNode`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.syntax/TypeAliasNode.pkl#L16,C1) from a [`JsonSchema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L22,C1). + schema: JsonSchema, +// ^^^^^^ definition local schema_191 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + typeAliasName: Type, +// ^^^^^^^^^^^^^ definition local typeAliasName_192 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ + typeNames: Type.TypeNames +// ^^^^^^^^^ definition local typeNames_193 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# + ): TypeAliasNode = new { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/ + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/name. + value = typeAliasName.name +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/value. +// ^^^^^^^^^^^^^ reference local typeAliasName_192 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/name. + } + docComment = getDocComment(schema, null) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/docComment. +// ^^^^^^^^^^^^^ reference local getDocComment_100 +// ^^^^^^ reference local schema_191 + type = typesGenerator.generateTypeNode(schema, typeNames.remove(schema)) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/type. +// ^^^^^^^^^^^^^^ reference local typesGenerator_53 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^ reference local schema_191 +// ^^^^^^^^^ reference local typeNames_193 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#remove(). +// ^^^^^^ reference local schema_191 + } + + function isClassLike(schema: JsonSchema.Schema): Boolean = +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/isClassLike(). +// ^^^^^^ definition local schema_202 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + if (schema is Boolean) +// ^^^^^^ reference local schema_202 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + false + else + // Edge case: if `$ref` exists, any other property should be ignored. + schema.$ref == null && schema.properties != null +// ^^^^^^ reference local schema_202 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$ref. +// ^^^^^^ reference local schema_202 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + + // only need to include stdlib names that would be used by the code generator + const local builtInNames = Set( +// ^^^^^^^^^^^^ definition local builtInNames_210 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). + "Mapping", + "Listing", + "Dynamic", + "String", + "Boolean", + "Int", + "Int16", + "Int32", + "UInt", + "UInt8", + "UInt16", + "UInt32", + "Float", + "Null", + "Number", + "Deprecated" + ) + + local function normalizeTypeName(name: String) = +// ^^^^^^^^^^^^^^^^^ definition local normalizeTypeName_229 +// ^^^^ definition local name_229 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (capitalized = utils.pascalCase(name)) +// ^^^^^^^^^^^ definition local capitalized_230 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/pascalCase(). +// ^^^^ reference local name_229 + if (builtInNames.contains(capitalized)) "\(capitalized)1" +// ^^^^^^^^^^^^ reference local builtInNames_210 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). +// ^^^^^^^^^^^ reference local capitalized_230 +// ^^^^^^^^^^^ reference local capitalized_230 + else capitalized +// ^^^^^^^^^^^ reference local capitalized_230 + + /// Determine the name of a type. + /// + /// Try to use the parent property's name as part of the class name in case of conflict. + /// If already at the root, add a number at the end. + local function determineTypeName(path: List, candidateName: String, existingTypeNames: Set, index: Int): Type = +// ^^^^^^^^^^^^^^^^^ definition local determineTypeName_234 +// documentation +// > Determine the name of a type. +// > +// > Try to use the parent property's name as part of the class name in case of conflict. +// > If already at the root, add a number at the end. +// ^^^^ definition local path_238 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^ definition local candidateName_238 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^^ definition local existingTypeNames_238 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ +// ^^^^^ definition local index_238 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ + let (candidateType = new Type { name = normalizeTypeName(candidateName); moduleName = module.moduleName }) +// ^^^^^^^^^^^^^ definition local candidateType_239 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/name. +// ^^^^^^^^^^^^^^^^^ reference local normalizeTypeName_229 +// ^^^^^^^^^^^^^ reference local candidateName_238 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleName. + if (existingTypeNames.contains(candidateType)) +// ^^^^^^^^^^^^^^^^^ reference local existingTypeNames_238 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). +// ^^^^^^^^^^^^^ reference local candidateType_239 + if (path.isEmpty) +// ^^^^ reference local path_238 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + determineTypeName(path, candidateName + index.toString(), existingTypeNames, index + 1) +// ^^^^^^^^^^^^^^^^^ reference local determineTypeName_234 +// ^^^^ reference local path_238 +// ^^^^^^^^^^^^^ reference local candidateName_238 +// ^^^^^ reference local index_238 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). +// ^^^^^^^^^^^^^^^^^ reference local existingTypeNames_238 +// ^^^^^ reference local index_238 + else + let (newPath = dropLast(path)) +// ^^^^^^^ definition local newPath_244 +// ^^^^^^^^ reference local dropLast_263 +// ^^^^ reference local path_238 + determineTypeName( +// ^^^^^^^^^^^^^^^^^ reference local determineTypeName_234 + newPath, +// ^^^^^^^ reference local newPath_244 + getCandidateName(newPath) + normalizeTypeName(candidateName), +// ^^^^^^^^^^^^^^^^ reference local getCandidateName_255 +// ^^^^^^^ reference local newPath_244 +// ^^^^^^^^^^^^^^^^^ reference local normalizeTypeName_229 +// ^^^^^^^^^^^^^ reference local candidateName_238 + existingTypeNames, +// ^^^^^^^^^^^^^^^^^ reference local existingTypeNames_238 + index +// ^^^^^ reference local index_238 + ) + else + candidateType +// ^^^^^^^^^^^^^ reference local candidateType_239 + + // noinspection TypeMismatch + local function getCandidateName(path: List) = +// ^^^^^^^^^^^^^^^^ definition local getCandidateName_255 +// ^^^^ definition local path_255 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (path.isEmpty) +// ^^^^ reference local path_255 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + "Item" + else if (path.last == "[]") +// ^^^^ reference local path_255 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + path.dropLast(1).lastOrNull?.ifNonNull((it) -> utils.pascalCase(singularize.singularize(it))) ?? "Item" +// ^^^^ reference local path_255 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#dropLast(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#lastOrNull. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_259 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/pascalCase(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/singularize.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/singularize.pkl`/singularize(). +// ^^ reference local it_259 + else + utils.pascalCase(path.last) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/pascalCase(). +// ^^^^ reference local path_255 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + + local function dropLast(path: List) = +// ^^^^^^^^ definition local dropLast_263 +// ^^^^ definition local path_263 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (path.last == "[]") +// ^^^^ reference local path_263 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + path.dropLast(2) +// ^^^^ reference local path_263 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#dropLast(). + else + path.dropLast(1) +// ^^^^ reference local path_263 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#dropLast(). + + /// The schemas that should be rendered as classes. + /// + /// Classes get rendered for any subschema that has [JsonSchema.properties] defined, and does not have [JsonSchema.`$ref`] defined. + local classSchemas: Type.TypeNames = +// ^^^^^^^^^^^^ definition local classSchemas_269 +// documentation +// > The schemas that should be rendered as classes. +// > +// > Classes get rendered for any subschema that has [`JsonSchema.properties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L325,C1) defined, and does not have `JsonSchema.`$ref`` defined. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# + let (schemas = utils._findMatchingSubSchemas(rootSchema, List(), (elem) -> elem != rootSchema && isClassLike(elem))) +// ^^^^^^^ definition local schemas_273 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/rootSchema. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^ definition local elem_273 +// ^^^^ reference local elem_273 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/isClassLike(). +// ^^^^ reference local elem_273 + let (collatedSchemas = +// ^^^^^^^^^^^^^^^ definition local collatedSchemas_274 + if (collatedRootSchema == rootSchema) Map() +// ^^^^^^^^^^^^^^^^^^ reference local collatedRootSchema_42 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/rootSchema. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + else utils._findMatchingSubSchemas( +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). + collatedRootSchema, +// ^^^^^^^^^^^^^^^^^^ reference local collatedRootSchema_42 + List(), +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + (elem) -> elem != collatedRootSchema && isClassLike(elem) +// ^^^^ definition local elem_279 +// ^^^^ reference local elem_279 +// ^^^^^^^^^^^^^^^^^^ reference local collatedRootSchema_42 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/isClassLike(). +// ^^^^ reference local elem_279 + ) + ) + (schemas + collatedSchemas) +// ^^^^^^^ reference local schemas_273 +// ^^^^^^^^^^^^^^^ reference local collatedSchemas_274 + .entries +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. + .fold(Map(), (accumulator: Type.TypeNames, pair) -> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^^^^^^ definition local accumulator_284 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^^ definition local pair_284 + let (path = pair.first) +// ^^^^ definition local path_285 +// ^^^^ reference local pair_284 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + let (schema = pair.second) +// ^^^^^^ definition local schema_286 +// ^^^^ reference local pair_284 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + let (typeName = determineTypeName(path, getCandidateName(path), accumulator.values.toSet(), 0)) +// ^^^^^^^^ definition local typeName_287 +// ^^^^^^^^^^^^^^^^^ reference local determineTypeName_234 +// ^^^^ reference local path_285 +// ^^^^^^^^^^^^^^^^ reference local getCandidateName_255 +// ^^^^ reference local path_285 +// ^^^^^^^^^^^ reference local accumulator_284 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toSet(). + accumulator.put(schema, typeName) +// ^^^^^^^^^^^ reference local accumulator_284 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#put(). +// ^^^^^^ reference local schema_286 +// ^^^^^^^^ reference local typeName_287 + ) + + local classNames: Set = classSchemas.values.toSet() +// ^^^^^^^^^^ definition local classNames_291 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ +// ^^^^^^^^^^^^ reference local classSchemas_269 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toSet(). + + /// The schemas that should be rendered as typealiases. + /// + /// This is done by traversing schema definintions. + /// Typealiases get rendered for any [JsonSchema.definitions] or [JsonSchema.`$defs`] that should not be rendered as a class. + local typeAliasSchemas: Type.TypeNames = +// ^^^^^^^^^^^^^^^^ definition local typeAliasSchemas_293 +// documentation +// > The schemas that should be rendered as typealiases. +// > +// > This is done by traversing schema definintions. +// > Typealiases get rendered for any [`JsonSchema.definitions`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L127,C1) or `JsonSchema.`$defs`` that should not be rendered as a class. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# + // Grab all schemas that have `definitions` or `$defs` + let (schemasWithDefinitions = utils._findMatchingSubSchemas(rootSchema, List(), (elem) -> (elem.definitions ?? elem.$defs) != null)) +// ^^^^^^^^^^^^^^^^^^^^^^ definition local schemasWithDefinitions_299 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/rootSchema. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^ definition local elem_299 +// ^^^^ reference local elem_299 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/definitions. +// ^^^^ reference local elem_299 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$defs. + let (collatedSchemasWithDefinitions = if (collatedRootSchema == rootSchema) Map() else utils._findMatchingSubSchemas(collatedRootSchema, List(), (elem) -> (elem.definitions ?? elem.$defs) != null)) +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition local collatedSchemasWithDefinitions_300 +// ^^^^^^^^^^^^^^^^^^ reference local collatedRootSchema_42 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/rootSchema. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). +// ^^^^^^^^^^^^^^^^^^ reference local collatedRootSchema_42 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^ definition local elem_300 +// ^^^^ reference local elem_300 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/definitions. +// ^^^^ reference local elem_300 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$defs. + (schemasWithDefinitions + collatedSchemasWithDefinitions) +// ^^^^^^^^^^^^^^^^^^^^^^ reference local schemasWithDefinitions_299 +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local collatedSchemasWithDefinitions_300 + .entries +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. + // For each schema, return the child json schema properties that are not class-like + .flatMap((pair) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#flatMap(). +// ^^^^ definition local pair_304 + let (path = pair.first) +// ^^^^ definition local path_305 +// ^^^^ reference local pair_304 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + let (schema = pair.second) +// ^^^^^^ definition local schema_306 +// ^^^^ reference local pair_304 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + (schema.definitions ?? schema.$defs ?? new Mapping {}).toMap() +// ^^^^^^ reference local schema_306 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/definitions. +// ^^^^^^ reference local schema_306 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$defs. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + .filter((_, value) -> value is JsonSchema && value.$ref == null && !isClassLike(value)) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^^ definition local value_308 +// ^^^^^ reference local value_308 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^ reference local value_308 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$ref. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/isClassLike(). +// ^^^^^ reference local value_308 + .mapKeys((key, _) -> path.add(key)) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#mapKeys(). +// ^^^ definition local key_309 +// ^^^^ reference local path_305 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local key_309 + .entries +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. + ) + .filter((pair) -> pair.second is JsonSchema) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filter(). +// ^^^^ definition local pair_312 +// ^^^^ reference local pair_312 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + .fold(Map(), (accumulator: Type.TypeNames, pair: Pair, JsonSchema.Schema>) -> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^^^^^^ definition local accumulator_313 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^^ definition local pair_313 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + if (pair.second is Boolean) +// ^^^^ reference local pair_313 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + accumulator +// ^^^^^^^^^^^ reference local accumulator_313 + else + let (schema = pair.second as JsonSchema) +// ^^^^^^ definition local schema_317 +// ^^^^ reference local pair_313 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + let (path = pair.first) +// ^^^^ definition local path_318 +// ^^^^ reference local pair_313 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + let (typeName = determineTypeName(path, path.last.capitalize(), accumulator.values.toSet() + classNames, 0)) +// ^^^^^^^^ definition local typeName_319 +// ^^^^^^^^^^^^^^^^^ reference local determineTypeName_234 +// ^^^^ reference local path_318 +// ^^^^ reference local path_318 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#capitalize(). +// ^^^^^^^^^^^ reference local accumulator_313 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toSet(). +// ^^^^^^^^^^ reference local classNames_291 + accumulator.put(schema, typeName) +// ^^^^^^^^^^^ reference local accumulator_313 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#put(). +// ^^^^^^ reference local schema_317 +// ^^^^^^^^ reference local typeName_319 + ) + diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/internal/ModulesGenerator.pkl b/pkl-pantrysnapshot/org.json_schema.contrib/internal/ModulesGenerator.pkl new file mode 100755 index 00000000..f7f6ba71 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/internal/ModulesGenerator.pkl @@ -0,0 +1,172 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.json_schema.contrib.internal.ModulesGenerator +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/ + + import "@jsonschema/JsonSchema.pkl" + import "@jsonschema/Parser.pkl" + import "@uri/URI.pkl" + import "utils.pkl" + import "ModuleGenerator.pkl" + + /// The root schema, used to resolve [JsonSchema.$ref] values. + rootSchema: JsonSchema +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/rootSchema. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + + /// The URI representing the root schema, used to resolve [JsonSchema.$ref] values. + baseUri: URI +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/baseUri. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + + local isExternalSchema = (baseUri: URI) -> (schema: JsonSchema) -> +// ^^^^^^^^^^^^^^^^ definition local isExternalSchema_30 +// ^^^^^^^ definition local baseUri_30 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ definition local schema_30 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + if (schema.$$refUri == null) false +// ^^^^^^ reference local schema_30 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$refUri. + else + let (resolvedUri = baseUri.resolveUri(schema.$$refUri!!)) +// ^^^^^^^^^^^ definition local resolvedUri_33 +// ^^^^^^^ reference local baseUri_30 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolveUri(). +// ^^^^^^ reference local schema_30 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$refUri. + baseUri.scheme != resolvedUri.scheme +// ^^^^^^^ reference local baseUri_30 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. +// ^^^^^^^^^^^ reference local resolvedUri_33 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. + || baseUri.authority() != resolvedUri.authority() +// ^^^^^^^ reference local baseUri_30 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/authority(). +// ^^^^^^^^^^^ reference local resolvedUri_33 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/authority(). + || baseUri.path != resolvedUri.path +// ^^^^^^^ reference local baseUri_30 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^^^^^^^ reference local resolvedUri_33 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. + + function gatherAllSchemas(schema: JsonSchema, baseUri: URI): List> = +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/gatherAllSchemas(). +// ^^^^^^ definition local schema_38 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ definition local baseUri_38 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + let (externalSchemas = utils.findMatchingSubschemas(schema, isExternalSchema.apply(baseUri))) +// ^^^^^^^^^^^^^^^ definition local externalSchemas_39 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/findMatchingSubschemas(). +// ^^^^^^ reference local schema_38 +// ^^^^^^^^^^^^^^^^ reference local isExternalSchema_30 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^^^ reference local baseUri_38 + externalSchemas.values.flatMap((it) -> +// ^^^^^^^^^^^^^^^ reference local externalSchemas_39 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#flatMap(). +// ^^ definition local it_40 + let (resolvedUri = baseUri.resolveUri(it.$$refUri!!).basePath) +// ^^^^^^^^^^^ definition local resolvedUri_41 +// ^^^^^^^ reference local baseUri_38 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolveUri(). +// ^^ reference local it_40 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$refUri. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/basePath. + let (jsonSchemaBlob = read?(resolvedUri.toString())) +// ^^^^^^^^^^^^^^ definition local jsonSchemaBlob_42 +// ^^^^^^^^^^^ reference local resolvedUri_41 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + if (jsonSchemaBlob == null) +// ^^^^^^^^^^^^^^ reference local jsonSchemaBlob_42 + let (_ = trace("WARN: Failed to read external URI \(resolvedUri)")) +// ^^^^^^^^^^^ reference local resolvedUri_41 + List() +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + else + let (parsedJsonSchema = (Parser.parse(jsonSchemaBlob)) { +// ^^^^^^^^^^^^^^^^ definition local parsedJsonSchema_47 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/parse(). +// ^^^^^^^^^^^^^^ reference local jsonSchemaBlob_42 + $$baseSchema = this +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/$$baseSchema. + }) + gatherAllSchemas(parsedJsonSchema, resolvedUri) +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/gatherAllSchemas(). +// ^^^^^^^^^^^^^^^^ reference local parsedJsonSchema_47 +// ^^^^^^^^^^^ reference local resolvedUri_41 + ).add(Pair(schema, baseUri)) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_38 +// ^^^^^^^ reference local baseUri_38 + + local schemas = gatherAllSchemas(rootSchema, baseUri) +// ^^^^^^^ definition local schemas_53 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/gatherAllSchemas(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/rootSchema. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/baseUri. + + modules: List = schemas.fold(List(), (acc: List, schema) -> +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/modules. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^ reference local schemas_53 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^ definition local acc_55 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^ definition local schema_55 + acc.add(new ModuleGenerator { +// ^^^ reference local acc_55 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ + rootSchema = schema.first +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_55 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + baseUri = schema.second +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/baseUri. +// ^^^^^^ reference local schema_55 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + existingTypes = acc.flatMap((it) -> it.moduleTypes.entries).toMap((it) -> it.first, (it) -> it.second) +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModulesGenerator.pkl`/existingTypes. +// ^^^ reference local acc_55 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#flatMap(). +// ^^ definition local it_59 +// ^^ reference local it_59 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleTypes. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toMap(). +// ^^ definition local it_59 +// ^^ reference local it_59 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^^ definition local it_59 +// ^^ reference local it_59 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + }) + ) + diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/internal/Type.pkl b/pkl-pantrysnapshot/org.json_schema.contrib/internal/Type.pkl new file mode 100755 index 00000000..e1d7c90c --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/internal/Type.pkl @@ -0,0 +1,35 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.json_schema.contrib.internal.Type +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ + + import "@jsonschema/JsonSchema.pkl" + import "Type.pkl" + + moduleName: String +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/moduleName. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + name: String +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + typealias TypeNames = Map +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ + diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/internal/TypesGenerator.pkl b/pkl-pantrysnapshot/org.json_schema.contrib/internal/TypesGenerator.pkl new file mode 100755 index 00000000..94a45bc6 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/internal/TypesGenerator.pkl @@ -0,0 +1,2480 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Logic for turning JSON Schemas into type nodes. + /// + /// A type node can be thought of as a type annotation; for example, it is `Int` within `foo: Int`. + /// + /// Class and typealias definitions are handled by [ClassGenerator] instead of here. + @Unlisted +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Unlisted# + module org.json_schema.contrib.internal.TypesGenerator +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ + + import "pkl:math" + import "@jsonschema/JsonSchema.pkl" + import "../ref.pkl" + import "@syntax/TypeNode.pkl" + import "@syntax/ExpressionNode.pkl" + import "@syntax/operators.pkl" + import "@uri/URI.pkl" + import "utils.pkl" + import "Type.pkl" + + /// The base URI, used to resolve `$ref` values. + baseUri: URI +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/baseUri. +//documentation +//> The base URI, used to resolve `$ref` values. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + + enclosingModuleName: String +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/enclosingModuleName. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Generate a Pkl type definition from a given schema. + /// + /// Expects class and typealias names to be known beforehand; [typeNames] is a map of a [JsonSchema] to its + /// determined declared name. + function generateTypeNode( +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// documentation +// > Generate a Pkl type definition from a given schema. +// > +// > Expects class and typealias names to be known beforehand; [`typeNames`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/internal/TypesGenerator.pkl#L45,C3) is a map of a [`JsonSchema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L22,C1) to its +// > determined declared name. + schema: JsonSchema.Schema, +// ^^^^^^ definition local schema_44 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + typeNames: Type.TypeNames +// ^^^^^^^^^ definition local typeNames_45 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# + ): TypeNode = +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + if (schema is JsonSchema && schema.$$refUri != null) +// ^^^^^^ reference local schema_44 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^ reference local schema_44 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$refUri. + let (resolved = ref.resolveRef(baseUri, schema)) +// ^^^^^^^^ definition local resolved_48 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/resolveRef(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/baseUri. +// ^^^^^^ reference local schema_44 + // Couldn't resolve the $ref, so mark this as an unknown type. + if (resolved == null) +// ^^^^^^^^ reference local resolved_48 + new TypeNode.BuiltInTypeNode { type = "unknown" } +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/BuiltInTypeNode# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/type. + else + generateTypeNode(resolved, typeNames) +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^ reference local resolved_48 +// ^^^^^^^^^ reference local typeNames_45 + else if (schema is JsonSchema && schema == schema.$$baseSchema) +// ^^^^^^ reference local schema_44 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^ reference local schema_44 +// ^^^^^^ reference local schema_44 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$baseSchema. + new TypeNode.BuiltInTypeNode { type = "module" } +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/BuiltInTypeNode# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/type. + // If a boolean, `true` means "anything is valid", `false` means "nothing is valid". + else if (schema is Boolean) +// ^^^^^^ reference local schema_44 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + if (schema) +// ^^^^^^ reference local schema_44 + utils.declaredType("Any") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + else + new TypeNode.BuiltInTypeNode { type = "nothing" } +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/BuiltInTypeNode# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/type. + // If we have generated a class or typealias definition already, simply use it. + else if (typeNames.containsKey(schema._inline_?.getOrNull("__ref_orig__") ?? schema)) +// ^^^^^^^^^ reference local typeNames_45 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#containsKey(). +// ^^^^^^ reference local schema_44 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/_inline_. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^ reference local schema_44 + let (type = typeNames[(schema._inline_?.getOrNull("__ref_orig__") ?? schema) as JsonSchema]) +// ^^^^ definition local type_64 +// ^^^^^^^^^ reference local typeNames_45 +// ^^^^^^ reference local schema_44 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/_inline_. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^ reference local schema_44 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + utils.declaredType1(type, type.moduleName != enclosingModuleName) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType1(). +// ^^^^ reference local type_64 +// ^^^^ reference local type_64 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/moduleName. +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/enclosingModuleName. + // Edge case: if `type` includes `"null"`, treat this as a nullable type. + else if (schema.type is Listing && schema.type.toList().contains("null")) +// ^^^^^^ reference local schema_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference local schema_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#contains(). + let (subtype = generateTypeNode((schema) { +// ^^^^^^^ definition local subtype_68 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^ reference local schema_44 + type = schema.type.toList().filter((t) -> t != "null").toListing() +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/type. +// ^^^^^^ reference local schema_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filter(). +// ^ definition local t_69 +// ^ reference local t_69 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toListing(). + }, typeNames)) +// ^^^^^^^^^ reference local typeNames_45 + new TypeNode.NullableTypeNode { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode# + typeNode = subtype +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/typeNode. +// ^^^^^^^ reference local subtype_68 + } + else + let (pair = generateBaseType(schema as JsonSchema, typeNames)) +// ^^^^ definition local pair_75 +// ^^^^^^^^^^^^^^^^ reference local generateBaseType_656 +// ^^^^^^ reference local schema_44 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ reference local typeNames_45 + pair.second |> addConstraints(pair.first) +// ^^^^ reference local pair_75 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^^^^^^^^^^^^ reference local addConstraints_398 +// ^^^^ reference local pair_75 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + + /// Node equivalent of `isBetween`. + /// + /// Returns null if either of minimum or maximum are missing. + local function constraintIsBetween(minimum: Number?, maximum: Number?): ExpressionNode.MemberAccessExpressionNode? = +// ^^^^^^^^^^^^^^^^^^^ definition local constraintIsBetween_78 +// documentation +// > Node equivalent of `isBetween`. +// > +// > Returns null if either of minimum or maximum are missing. +// ^^^^^^^ definition local minimum_81 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^ definition local maximum_81 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + if (minimum != null && maximum != null) +// ^^^^^^^ reference local minimum_81 +// ^^^^^^^ reference local maximum_81 + new { + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "isBetween" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + arguments { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/arguments. + utils.numberLiteral(minimum) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^^ reference local minimum_81 + utils.numberLiteral(maximum) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^^ reference local maximum_81 + } + } + else null + + /// Node equivalent of `length.isBetween(...)`, given the minimum and maximum values. + local function constraintLengthIsBetween(minimum: Number?, maximum: Number?): ExpressionNode? = +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition local constraintLengthIsBetween_94 +// documentation +// > Node equivalent of `length.isBetween(...)`, given the minimum and maximum values. +// ^^^^^^^ definition local minimum_95 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^ definition local maximum_95 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + let (isBetween = constraintIsBetween(minimum, maximum)) +// ^^^^^^^^^ definition local isBetween_96 +// ^^^^^^^^^^^^^^^^^^^ reference local constraintIsBetween_78 +// ^^^^^^^ reference local minimum_95 +// ^^^^^^^ reference local maximum_95 + if (isBetween != null) +// ^^^^^^^^^ reference local isBetween_96 + new ExpressionNode.QualifiedMemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode# + lhs = new ExpressionNode.MemberAccessExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "length" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + } + rhs = isBetween +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/rhs. +// ^^^^^^^^^ reference local isBetween_96 + } + else null + + /// Node equivalent of `isEmpty` or `!isEmpty`. + local function constraintIsEmpty(minimum: Number?, maximum: Number?): ExpressionNode? = +// ^^^^^^^^^^^^^^^^^ definition local constraintIsEmpty_108 +// documentation +// > Node equivalent of `isEmpty` or `!isEmpty`. +// ^^^^^^^ definition local minimum_109 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^ definition local maximum_109 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + let (IS_EMPTY = new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^ definition local IS_EMPTY_110 +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "isEmpty" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + }) + if (minimum == null && maximum == 0) +// ^^^^^^^ reference local minimum_109 +// ^^^^^^^ reference local maximum_109 + IS_EMPTY +// ^^^^^^^^ reference local IS_EMPTY_110 + else if (minimum == 1 && maximum == null) +// ^^^^^^^ reference local minimum_109 +// ^^^^^^^ reference local maximum_109 + new ExpressionNode.PrefixOperatorExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode# + operator = operators.NOT +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/operator. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NOT. + expression = IS_EMPTY +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/expression. +// ^^^^^^^^ reference local IS_EMPTY_110 + } + else null + + /// Node equivalent of `isPositive` or `!isPositive`. + local function numberConstraintsIsPositive(minimum: Number?, maximum: Number?): ExpressionNode? = +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition local numberConstraintsIsPositive_124 +// documentation +// > Node equivalent of `isPositive` or `!isPositive`. +// ^^^^^^^ definition local minimum_125 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^ definition local maximum_125 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + if (minimum == 0 && maximum == null) +// ^^^^^^^ reference local minimum_125 +// ^^^^^^^ reference local maximum_125 + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "isPositive" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + } + else if (minimum == null && maximum == -1) +// ^^^^^^^ reference local minimum_125 +// ^^^^^^^ reference local maximum_125 + new ExpressionNode.PrefixOperatorExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode# + operator = operators.NOT +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/operator. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NOT. + expression = new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/expression. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "isPositive" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + } + } + else null + + /// Constraints on numbers. + local function numberConstraints(schema: JsonSchema): List = +// ^^^^^^^^^^^^^^^^^ definition local numberConstraints_143 +// documentation +// > Constraints on numbers. +// ^^^^^^ definition local schema_144 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + if (!isNumberSchema(schema)) +// ^^^^^^^^^^^^^^ reference local isNumberSchema_631 +// ^^^^^^ reference local schema_144 + List() +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + else + let (minimum = if (schema.exclusiveMinimum != null) schema.exclusiveMinimum!! + 1 else schema.minimum) +// ^^^^^^^ definition local minimum_148 +// ^^^^^^ reference local schema_144 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMinimum. +// ^^^^^^ reference local schema_144 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMinimum. +// ^^^^^^ reference local schema_144 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minimum. + let (maximum = if (schema.exclusiveMaximum != null) schema.exclusiveMaximum!! - 1 else schema.maximum) +// ^^^^^^^ definition local maximum_149 +// ^^^^^^ reference local schema_144 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMaximum. +// ^^^^^^ reference local schema_144 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMaximum. +// ^^^^^^ reference local schema_144 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maximum. + let (isBetween = constraintIsBetween(minimum, maximum)) +// ^^^^^^^^^ definition local isBetween_150 +// ^^^^^^^^^^^^^^^^^^^ reference local constraintIsBetween_78 +// ^^^^^^^ reference local minimum_148 +// ^^^^^^^ reference local maximum_149 + let (isPositive = numberConstraintsIsPositive(minimum, maximum)) +// ^^^^^^^^^^ definition local isPositive_151 +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local numberConstraintsIsPositive_124 +// ^^^^^^^ reference local minimum_148 +// ^^^^^^^ reference local maximum_149 + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + when (isBetween != null) { +// ^^^^^^^^^ reference local isBetween_150 + isBetween +// ^^^^^^^^^ reference local isBetween_150 + } + when (isPositive != null) { +// ^^^^^^^^^^ reference local isPositive_151 + isPositive +// ^^^^^^^^^^ reference local isPositive_151 + } + when (isPositive == null && isBetween == null) { +// ^^^^^^^^^^ reference local isPositive_151 +// ^^^^^^^^^ reference local isBetween_150 + when (schema.minimum != null) { +// ^^^^^^ reference local schema_144 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minimum. + utils.binaryOperatorNode(utils.THIS, operators.GREATER_THAN_OR_EQUALS, utils.numberLiteral(schema.minimum!!)) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/THIS. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN_OR_EQUALS. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^ reference local schema_144 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minimum. + } + + when (schema.exclusiveMinimum != null) { +// ^^^^^^ reference local schema_144 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMinimum. + utils.binaryOperatorNode(utils.THIS, operators.GREATER_THAN, utils.numberLiteral(schema.exclusiveMinimum!!)) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/THIS. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^ reference local schema_144 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMinimum. + } + + when (schema.maximum != null) { +// ^^^^^^ reference local schema_144 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maximum. + utils.binaryOperatorNode(utils.THIS, operators.LESS_THAN_OR_EQUALS, utils.numberLiteral(schema.maximum!!)) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/THIS. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN_OR_EQUALS. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^ reference local schema_144 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maximum. + } + + when (schema.exclusiveMaximum != null) { +// ^^^^^^ reference local schema_144 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMaximum. + utils.binaryOperatorNode(utils.THIS, operators.LESS_THAN, utils.numberLiteral(schema.exclusiveMaximum!!)) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/THIS. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^ reference local schema_144 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMaximum. + } + } + when (schema.multipleOf != null) { +// ^^^^^^ reference local schema_144 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. + if (schema.multipleOf == 2) +// ^^^^^^ reference local schema_144 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "isEven" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + } + else + utils.binaryOperatorNode( +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). + utils.binaryOperatorNode(utils.THIS, operators.MODULO, utils.numberLiteral(schema.multipleOf!!)), +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/THIS. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/MODULO. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^ reference local schema_144 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. + operators.EQUALS, +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/EQUALS. + utils.numberLiteral(0) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). + ) + } + }.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + + local function arrayConstraints(schema: JsonSchema): List = +// ^^^^^^^^^^^^^^^^ definition local arrayConstraints_192 +// ^^^^^^ definition local schema_192 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + if (!isListingSchema(schema)) +// ^^^^^^^^^^^^^^^ reference local isListingSchema_646 +// ^^^^^^ reference local schema_192 + List() +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + else + let (isBetween = constraintLengthIsBetween(schema.minItems, schema.maxItems)) +// ^^^^^^^^^ definition local isBetween_196 +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference local constraintLengthIsBetween_94 +// ^^^^^^ reference local schema_192 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minItems. +// ^^^^^^ reference local schema_192 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxItems. + let (isEmpty = constraintIsEmpty(schema.minItems, schema.maxItems)) +// ^^^^^^^ definition local isEmpty_197 +// ^^^^^^^^^^^^^^^^^ reference local constraintIsEmpty_108 +// ^^^^^^ reference local schema_192 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minItems. +// ^^^^^^ reference local schema_192 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxItems. + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + when (isBetween != null) { +// ^^^^^^^^^ reference local isBetween_196 + isBetween +// ^^^^^^^^^ reference local isBetween_196 + } + when (isEmpty != null) { +// ^^^^^^^ reference local isEmpty_197 + isEmpty +// ^^^^^^^ reference local isEmpty_197 + } + when (isBetween == null && isEmpty == null) { +// ^^^^^^^^^ reference local isBetween_196 +// ^^^^^^^ reference local isEmpty_197 + when (schema.minItems != null) { +// ^^^^^^ reference local schema_192 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minItems. + utils.binaryOperatorNode(new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "length" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + }, operators.GREATER_THAN_OR_EQUALS, utils.numberLiteral(schema.minItems!!)) +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN_OR_EQUALS. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^ reference local schema_192 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minItems. + } + + when (schema.maxItems != null) { +// ^^^^^^ reference local schema_192 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxItems. + utils.binaryOperatorNode(new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "length" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + }, operators.LESS_THAN_OR_EQUALS, utils.numberLiteral(schema.maxItems!!)) +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN_OR_EQUALS. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^ reference local schema_192 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxItems. + } + } + when (schema.uniqueItems == true) { +// ^^^^^^ reference local schema_192 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/uniqueItems. + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "isDistinct" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + } + } + }.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + + local function stringConstraints(schema: JsonSchema): List = +// ^^^^^^^^^^^^^^^^^ definition local stringConstraints_231 +// ^^^^^^ definition local schema_231 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + if (!isStringSchema(schema)) +// ^^^^^^^^^^^^^^ reference local isStringSchema_636 +// ^^^^^^ reference local schema_231 + List() +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + else + let (isBetween = constraintLengthIsBetween(schema.minLength, schema.maxLength)) +// ^^^^^^^^^ definition local isBetween_235 +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference local constraintLengthIsBetween_94 +// ^^^^^^ reference local schema_231 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minLength. +// ^^^^^^ reference local schema_231 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxLength. + let (isEmpty = constraintIsEmpty(schema.minLength, schema.maxLength)) +// ^^^^^^^ definition local isEmpty_236 +// ^^^^^^^^^^^^^^^^^ reference local constraintIsEmpty_108 +// ^^^^^^ reference local schema_231 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minLength. +// ^^^^^^ reference local schema_231 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxLength. + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + when (isBetween != null) { +// ^^^^^^^^^ reference local isBetween_235 + isBetween +// ^^^^^^^^^ reference local isBetween_235 + } + when (isEmpty != null) { +// ^^^^^^^ reference local isEmpty_236 + isEmpty +// ^^^^^^^ reference local isEmpty_236 + } + when (isBetween == null && isEmpty == null) { +// ^^^^^^^^^ reference local isBetween_235 +// ^^^^^^^ reference local isEmpty_236 + when (schema.minLength != null) { +// ^^^^^^ reference local schema_231 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minLength. + utils.binaryOperatorNode(new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "length" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + }, operators.GREATER_THAN_OR_EQUALS, utils.numberLiteral(schema.minLength!!)) +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN_OR_EQUALS. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^ reference local schema_231 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minLength. + } + + when (schema.maxLength != null) { +// ^^^^^^ reference local schema_231 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxLength. + utils.binaryOperatorNode(new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "length" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + }, operators.LESS_THAN_OR_EQUALS, utils.numberLiteral(schema.maxLength!!)) +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN_OR_EQUALS. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^ reference local schema_231 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxLength. + } + } + + when (schema.pattern != null) { +// ^^^^^^ reference local schema_231 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/pattern. + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "matches" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + arguments { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/arguments. + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "Regex" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + arguments { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/arguments. + new ExpressionNode.LiteralValueExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = schema.pattern +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. +// ^^^^^^ reference local schema_231 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/pattern. + } + } + } + } + } + } + + // For formats, regex is easy, but not really clear how to describe anything else. + when (schema.format == "regex") { +// ^^^^^^ reference local schema_231 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/format. + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "isRegex" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + } + } + }.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + + /// Constraints for [Mapping] types. + /// + /// Note: [JsonSchema.patternProperties] is handled in the base type rather than as a constraint. + local function mappingConstraints(schema: JsonSchema): List = +// ^^^^^^^^^^^^^^^^^^ definition local mappingConstraints_292 +// documentation +// > Constraints for [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7) types. +// > +// > Note: [`JsonSchema.patternProperties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L337,C1) is handled in the base type rather than as a constraint. +// ^^^^^^ definition local schema_295 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + if (!isMappingSchema(schema)) +// ^^^^^^^^^^^^^^^ reference local isMappingSchema_651 +// ^^^^^^ reference local schema_295 + List() +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + else + let (isBetween = constraintLengthIsBetween(schema.minProperties, schema.maxProperties)) +// ^^^^^^^^^ definition local isBetween_299 +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference local constraintLengthIsBetween_94 +// ^^^^^^ reference local schema_295 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minProperties. +// ^^^^^^ reference local schema_295 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxProperties. + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + when (isBetween != null) { +// ^^^^^^^^^ reference local isBetween_299 + isBetween +// ^^^^^^^^^ reference local isBetween_299 + } + when (isBetween == null) { +// ^^^^^^^^^ reference local isBetween_299 + when (schema.minProperties != null) { +// ^^^^^^ reference local schema_295 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minProperties. + utils.binaryOperatorNode(new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "length" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + }, operators.GREATER_THAN_OR_EQUALS, utils.numberLiteral(schema.minProperties!!)) +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN_OR_EQUALS. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^ reference local schema_295 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minProperties. + } + + when (schema.maxProperties != null) { +// ^^^^^^ reference local schema_295 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxProperties. + utils.binaryOperatorNode(new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "length" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + }, operators.LESS_THAN_OR_EQUALS, utils.numberLiteral(schema.maxProperties!!)) +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN_OR_EQUALS. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// ^^^^^^ reference local schema_295 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxProperties. + } + } + }.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + + /// Internal implementation of [literalValueConstraints] + /// + /// [enums] must be a non-empty array. + local function literalValueConstraintsImpl(enums: List): ExpressionNode = +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition local literalValueConstraintsImpl_323 +// documentation +// > Internal implementation of `literalValueConstraints` +// > +// > [`enums`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/internal/TypesGenerator.pkl#L326,C44) must be a non-empty array. +// ^^^^^ definition local enums_326 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + if (enums.length == 1) +// ^^^^^ reference local enums_326 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. + new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = utils.THIS +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/lhs. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/THIS. + operator = operators.EQUALS +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/operator. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/EQUALS. + rhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = enums[0] +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. +// ^^^^^ reference local enums_326 + } + } + else + new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = utils.THIS +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/lhs. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/THIS. + operator = operators.EQUALS +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/operator. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/EQUALS. + rhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = enums[0] +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. +// ^^^^^ reference local enums_326 + } + } + operator = operators.OR +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/operator. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/OR. + rhs = literalValueConstraintsImpl(enums.drop(1)) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local literalValueConstraintsImpl_323 +// ^^^^^ reference local enums_326 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). + } + + /// Node equivalent of literal value restrictions. + /// + /// Given `"enum": [1, 2, 3, 4]`, generates `this == 1 || this == 2 || this == 3 || this == 4` + /// Note: enums of strings is not handled by this; it is generated as a union type of string literals instead by [generateBaseType]. + local function literalValueConstraints(schema: JsonSchema): List = +// ^^^^^^^^^^^^^^^^^^^^^^^ definition local literalValueConstraints_348 +// documentation +// > Node equivalent of literal value restrictions. +// > +// > Given `"enum": `1, 2, 3, 4``, generates `this == 1 || this == 2 || this == 3 || this == 4` +// > Note: enums of strings is not handled by this; it is generated as a union type of string literals instead by `generateBaseType`. +// ^^^^^^ definition local schema_352 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + if (schema.enum == null && schema.`const` == null) +// ^^^^^^ reference local schema_352 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^ reference local schema_352 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/const. + List() +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + else + let (enums = +// ^^^^^ definition local enums_356 + if (schema.enum is Listing) schema.enum.toList() +// ^^^^^^ reference local schema_352 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference local schema_352 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + else if (schema.`const` != null) List(schema.`const`) +// ^^^^^^ reference local schema_352 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/const. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^ reference local schema_352 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/const. + else List(schema.enum)) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^ reference local schema_352 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. + let (filteredEnums = enums.filter((enum) -> enum is String|Boolean|Number|Null) as List) +// ^^^^^^^^^^^^^ definition local filteredEnums_360 +// ^^^^^ reference local enums_356 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filter(). +// ^^^^ definition local enum_360 +// ^^^^ reference local enum_360 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# + if (filteredEnums.isEmpty) +// ^^^^^^^^^^^^^ reference local filteredEnums_360 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + List() +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + // "enum": [true, false] is exactly the same meaning as Boolean, so skip generating literal value constraints. + else if (filteredEnums.toSet() == Set(true, false)) +// ^^^^^^^^^^^^^ reference local filteredEnums_360 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toSet(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). + List() +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + else + List(literalValueConstraintsImpl(filteredEnums)) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local literalValueConstraintsImpl_323 +// ^^^^^^^^^^^^^ reference local filteredEnums_360 + + /// Table of binary operators to its exact opposite. + /// + /// This is used to render a nicer constraint and avoid using `!`. + /// For example, we want `this > 5` instead of `!(this <= 4)` + local antonyms: Mapping = new { +// ^^^^^^^^ definition local antonyms_369 +// documentation +// > Table of binary operators to its exact opposite. +// > +// > This is used to render a nicer constraint and avoid using `!`. +// > For example, we want `this > 5` instead of `!(this <= 4)` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BinaryOperator# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BinaryOperator# + [operators.GREATER_THAN] = operators.LESS_THAN_OR_EQUALS +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN_OR_EQUALS. + [operators.GREATER_THAN_OR_EQUALS] = operators.LESS_THAN +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN_OR_EQUALS. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN. + [operators.LESS_THAN] = operators.GREATER_THAN_OR_EQUALS +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN_OR_EQUALS. + [operators.LESS_THAN_OR_EQUALS] = operators.GREATER_THAN +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN_OR_EQUALS. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN. + [operators.EQUALS] = operators.NOT_EQUALS +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/EQUALS. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NOT_EQUALS. + [operators.NOT_EQUALS] = operators.EQUALS +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NOT_EQUALS. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/EQUALS. + } + + local memberAccessAntonyms: Mapping = new { +// ^^^^^^^^^^^^^^^^^^^^ definition local memberAccessAntonyms_382 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + ["isOdd"] = "isEven" + ["isEven"] = "isOdd" + ["isFinite"] = "isInfinite" + ["isInfinite"] = "isFinite" + } + + local function constraintExpressions(schema: JsonSchema.Schema): List = +// ^^^^^^^^^^^^^^^^^^^^^ definition local constraintExpressions_389 +// ^^^^^^ definition local schema_389 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + if (schema is Boolean) List() +// ^^^^^^ reference local schema_389 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + else + numberConstraints(schema as JsonSchema) +// ^^^^^^^^^^^^^^^^^ reference local numberConstraints_143 +// ^^^^^^ reference local schema_389 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + + arrayConstraints(schema as JsonSchema) +// ^^^^^^^^^^^^^^^^ reference local arrayConstraints_192 +// ^^^^^^ reference local schema_389 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + + stringConstraints(schema as JsonSchema) +// ^^^^^^^^^^^^^^^^^ reference local stringConstraints_231 +// ^^^^^^ reference local schema_389 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + + mappingConstraints(schema as JsonSchema) +// ^^^^^^^^^^^^^^^^^^ reference local mappingConstraints_292 +// ^^^^^^ reference local schema_389 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + + literalValueConstraints(schema as JsonSchema) +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local literalValueConstraints_348 +// ^^^^^^ reference local schema_389 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + + /// Constraints to be added to a base type. + /// + /// This will use "nicer" constraints if available. + /// For exmaple, `isBetween`, `isPositive`, `isEven`, etc. + /// + /// **NOTE**: If `schema.type` is a [Listing], the schema might contain constraints that are only relevant to one of the subtypes. + /// For example, a schema might have `"type": ["string", "array"]` and have `uniqueItems` set. + /// In this situation, `uniqueItems` should apply to only the "array" subtype. + /// We accomplish this by only applying constraints when the type is detected to be exactly the desired subtype. + /// When generating base types, we split the types into a union type, and synthesize a subschema of that type. + local function addConstraints(schema: JsonSchema): Mixin = (_typeNode) -> +// ^^^^^^^^^^^^^^ definition local addConstraints_398 +// documentation +// > Constraints to be added to a base type. +// > +// > This will use "nicer" constraints if available. +// > For exmaple, `isBetween`, `isPositive`, `isEven`, etc. +// > +// > **NOTE**: If `schema.type` is a [`Listing`](pkl-lsp://stdlib/base.pkl#L1860,C7), the schema might contain constraints that are only relevant to one of the subtypes. +// > For example, a schema might have `"type": `"string", "array"`` and have `uniqueItems` set. +// > In this situation, `uniqueItems` should apply to only the "array" subtype. +// > We accomplish this by only applying constraints when the type is detected to be exactly the desired subtype. +// > When generating base types, we split the types into a union type, and synthesize a subschema of that type. +// ^^^^^^ definition local schema_408 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mixin# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ +// ^^^^^^^^^ definition local _typeNode_408 + let (baseConstraints = constraintExpressions(schema)) +// ^^^^^^^^^^^^^^^ definition local baseConstraints_409 +// ^^^^^^^^^^^^^^^^^^^^^ reference local constraintExpressions_389 +// ^^^^^^ reference local schema_408 + let (notConstraints = +// ^^^^^^^^^^^^^^ definition local notConstraints_410 + if (schema.not == null) List() +// ^^^^^^ reference local schema_408 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/not. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + else + let (_not = (schema.not!!) { type = schema.type }) +// ^^^^ definition local _not_413 +// ^^^^^^ reference local schema_408 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/not. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/type. +// ^^^^^^ reference local schema_408 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. + constraintExpressions(_not).map((_expression) -> +// ^^^^^^^^^^^^^^^^^^^^^ reference local constraintExpressions_389 +// ^^^^ reference local _not_413 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^^^^^^^^ definition local _expression_414 + // `isOdd` instead of `!isEven` etc + if (_expression is ExpressionNode.MemberAccessExpressionNode && memberAccessAntonyms.containsKey(_expression.identifier.value)) +// ^^^^^^^^^^^ reference local _expression_414 +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# +// ^^^^^^^^^^^^^^^^^^^^ reference local memberAccessAntonyms_382 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). +// ^^^^^^^^^^^ reference local _expression_414 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#identifier. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/value. + (_expression) { +// ^^^^^^^^^^^ reference local _expression_414 + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = memberAccessAntonyms[_expression.identifier.value] +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. +// ^^^^^^^^^^^^^^^^^^^^ reference local memberAccessAntonyms_382 +// ^^^^^^^^^^^ reference local _expression_414 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#identifier. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/value. + } + } + // Use antonyms if available. For example, we can use the expression `this > 5` instead of `!(this <= 4)` + else if (_expression is ExpressionNode.BinaryOperatorExpressionNode && antonyms.containsKey(_expression.operator)) +// ^^^^^^^^^^^ reference local _expression_414 +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# +// ^^^^^^^^ reference local antonyms_369 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). +// ^^^^^^^^^^^ reference local _expression_414 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#operator. + (_expression) { +// ^^^^^^^^^^^ reference local _expression_414 + operator = antonyms[_expression.operator] +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/operator. +// ^^^^^^^^ reference local antonyms_369 +// ^^^^^^^^^^^ reference local _expression_414 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#operator. + } + else + new ExpressionNode.PrefixOperatorExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode# + operator = operators.NOT +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/operator. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NOT. + expression = _expression +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/expression. +// ^^^^^^^^^^^ reference local _expression_414 + }) + ) + let (allOfConstraints = +// ^^^^^^^^^^^^^^^^ definition local allOfConstraints_433 + if (schema.allOf == null) List() +// ^^^^^^ reference local schema_408 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/allOf. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + else + let (merged = utils.mergeSchemas(schema, schema.allOf!!.toList())) +// ^^^^^^ definition local merged_436 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/mergeSchemas(). +// ^^^^^^ reference local schema_408 +// ^^^^^^ reference local schema_408 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/allOf. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + constraintExpressions(merged) +// ^^^^^^^^^^^^^^^^^^^^^ reference local constraintExpressions_389 +// ^^^^^^ reference local merged_436 + ) + let (allConstraints = baseConstraints + notConstraints + allOfConstraints) +// ^^^^^^^^^^^^^^ definition local allConstraints_439 +// ^^^^^^^^^^^^^^^ reference local baseConstraints_409 +// ^^^^^^^^^^^^^^ reference local notConstraints_410 +// ^^^^^^^^^^^^^^^^ reference local allOfConstraints_433 + if (allConstraints.isEmpty) +// ^^^^^^^^^^^^^^ reference local allConstraints_439 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + _typeNode +// ^^^^^^^^^ reference local _typeNode_408 + else + new TypeNode.ConstrainedTypeNode { typeNode = _typeNode; constraints = allConstraints.toListing() } +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/typeNode. +// ^^^^^^^^^ reference local _typeNode_408 +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/constraints. +// ^^^^^^^^^^^^^^ reference local allConstraints_439 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toListing(). + + /// Generates the declared type of a schema, without constraints. + /// + /// The base type might already represent some of the JSON Schema's constraints. For instance, + /// `UInt32` already signifies a minimum and a maximum. + /// + /// If the base type represents this information, it is removed from the returned [JsonSchema] so + /// we do not end up with redundant constraints like `UInt32(isBetween(0, 4294967295))`. + local function generateNumberType(schema: JsonSchema): Pair = +// ^^^^^^^^^^^^^^^^^^ definition local generateNumberType_445 +// documentation +// > Generates the declared type of a schema, without constraints. +// > +// > The base type might already represent some of the JSON Schema's constraints. For instance, +// > `UInt32` already signifies a minimum and a maximum. +// > +// > If the base type represents this information, it is removed from the returned [`JsonSchema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L22,C1) so +// > we do not end up with redundant constraints like `UInt32(isBetween(0, 4294967295))`. +// ^^^^^^ definition local schema_452 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + let (isInt = schema.type == "integer" || (schema.multipleOf != null && schema.multipleOf == schema.multipleOf?.floor)) +// ^^^^^ definition local isInt_453 +// ^^^^^^ reference local schema_452 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^ reference local schema_452 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. +// ^^^^^^ reference local schema_452 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. +// ^^^^^^ reference local schema_452 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#floor. + if (isInt) +// ^^^^^ reference local isInt_453 + let (minimum = if (schema.exclusiveMinimum != null) schema.exclusiveMinimum!! + 1 else schema.minimum) +// ^^^^^^^ definition local minimum_455 +// ^^^^^^ reference local schema_452 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMinimum. +// ^^^^^^ reference local schema_452 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMinimum. +// ^^^^^^ reference local schema_452 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minimum. + let (maximum = if (schema.exclusiveMaximum != null) schema.exclusiveMaximum!! - 1 else schema.maximum) +// ^^^^^^^ definition local maximum_456 +// ^^^^^^ reference local schema_452 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMaximum. +// ^^^^^^ reference local schema_452 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMaximum. +// ^^^^^^ reference local schema_452 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maximum. + let (refinedInt = +// ^^^^^^^^^^ definition local refinedInt_457 + if (minimum == 0 && maximum == math.maxUInt32) +// ^^^^^^^ reference local minimum_455 +// ^^^^^^^ reference local maximum_456 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + utils.declaredType("UInt32") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + else if (minimum == 0 && maximum == math.maxUInt16) +// ^^^^^^^ reference local minimum_455 +// ^^^^^^^ reference local maximum_456 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt16. + utils.declaredType("UInt16") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + else if (minimum == 0 && maximum == math.maxUInt8) +// ^^^^^^^ reference local minimum_455 +// ^^^^^^^ reference local maximum_456 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt8. + utils.declaredType("UInt8") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + else if (minimum == math.minInt32 && maximum == math.maxInt32) +// ^^^^^^^ reference local minimum_455 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/minInt32. +// ^^^^^^^ reference local maximum_456 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxInt32. + utils.declaredType("Int32") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + else if (minimum == math.minInt16 && maximum == math.maxInt16) +// ^^^^^^^ reference local minimum_455 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/minInt16. +// ^^^^^^^ reference local maximum_456 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxInt16. + utils.declaredType("Int16") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + else if (minimum == math.minInt8 && maximum == math.maxInt8) +// ^^^^^^^ reference local minimum_455 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/minInt8. +// ^^^^^^^ reference local maximum_456 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxInt8. + utils.declaredType("Int8") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + else null + ) + let (_schema = (schema) { +// ^^^^^^^ definition local _schema_472 +// ^^^^^^ reference local schema_452 + when (refinedInt != null) { +// ^^^^^^^^^^ reference local refinedInt_457 + minimum = null +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/minimum. + maximum = null +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/maximum. + exclusiveMinimum = null +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/exclusiveMinimum. + exclusiveMaximum = null +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/exclusiveMaximum. + } + // `multipleOf: 1` is redundant if the type is already [Int]. + when (schema.multipleOf == 1) { +// ^^^^^^ reference local schema_452 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. + multipleOf = null +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/multipleOf. + } + }) + Pair(_schema, refinedInt ?? utils.declaredType("Int")) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^^ reference local _schema_472 +// ^^^^^^^^^^ reference local refinedInt_457 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + else + Pair(schema, utils.declaredType("Number")) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_452 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + + local function generateStringType(schema: JsonSchema): Pair = +// ^^^^^^^^^^^^^^^^^^ definition local generateStringType_488 +// ^^^^^^ definition local schema_488 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + if (schema.`const` is String) +// ^^^^^^ reference local schema_488 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/const. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + Pair((schema) { `const` = null }, new TypeNode.StringLiteralTypeNode { value = schema.`const` as String }) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_488 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/const. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. +// ^^^^^^ reference local schema_488 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/const. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + else if (schema.enum != null && schema.enum is String) +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + Pair((schema) { enum = null }, new TypeNode.StringLiteralTypeNode { value = schema.enum as String }) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_488 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/enum. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + else if (schema.enum != null && schema.enum is Listing && schema.enum.length == 1 && schema.enum.toList().first is String) +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#length. +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + Pair((schema) { enum = null }, new TypeNode.StringLiteralTypeNode { value = (schema.enum as Listing).toList().first }) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_488 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/enum. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. + else if (schema.enum != null && schema.enum is Listing && schema.enum.toList().every((val) -> val is String)) +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^^ definition local val_495 +// ^^^ reference local val_495 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + // Edge case: If `enum` is set to all strings, this should be a union type. + Pair( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). + (schema) { enum = null }, +// ^^^^^^ reference local schema_488 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/enum. + new TypeNode.UnionTypeNode { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode# + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/members. + for (stringValue in schema.enum as Listing) { +// ^^^^^^^^^^^ definition local stringValue_501 +// ^^^^^^ reference local schema_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + new TypeNode.StringLiteralTypeNode { value = stringValue } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. +// ^^^^^^^^^^^ reference local stringValue_501 + } + } + } + ) + else if (schema.format == "uri") +// ^^^^^^ reference local schema_488 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/format. + Pair((schema) { format = null }, utils.declaredType("Uri")) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_488 +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/format. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + else + Pair(schema, utils.declaredType("String")) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_488 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + + local function generateObjectType(schema: JsonSchema, typeNames: Type.TypeNames): TypeNode = +// ^^^^^^^^^^^^^^^^^^ definition local generateObjectType_512 +// ^^^^^^ definition local schema_512 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ definition local typeNames_512 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + // If `patternProperties` has exactly one entry, we can convert this to a `Mapping` where + // the key is in the form of `String(matches(...))`. + // Otherwise if it has more keys, we can't really express a good constraint for this, because `Mapping`s + // have homogenous types for each key-value pair, and classes cannot have entries. + // In the latter case, simply fall back to `Dynamic`. + if (schema.patternProperties != null && schema.patternProperties.toMap().length == 1) +// ^^^^^^ reference local schema_512 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/patternProperties. +// ^^^^^^ reference local schema_512 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/patternProperties. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#length. + let (pair = schema.patternProperties.toMap().entries.first) +// ^^^^ definition local pair_519 +// ^^^^^^ reference local schema_512 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/patternProperties. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. + (utils.declaredType("Mapping")) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + typeArguments { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/typeArguments. + new TypeNode.ConstrainedTypeNode { +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode# + typeNode = utils.declaredType("String") +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/typeNode. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + constraints { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/constraints. + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "matches" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + arguments { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/arguments. + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/identifier. + value = "Regex" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. + } + arguments { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/arguments. + new ExpressionNode.LiteralValueExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = pair.first +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/value. +// ^^^^ reference local pair_519 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + } + } + } + } + } + } + } + generateTypeNode(pair.second, typeNames) +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^ reference local pair_519 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^^^^^^^ reference local typeNames_512 + } + } + else if (schema.additionalProperties != null) +// ^^^^^^ reference local schema_512 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. + (utils.declaredType("Mapping")) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + typeArguments { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/typeArguments. + utils.declaredType("String") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + if (schema.additionalProperties is Boolean) +// ^^^^^^ reference local schema_512 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + utils.declaredType("Any") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + else + generateTypeNode(schema.additionalProperties as JsonSchema, typeNames) +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^ reference local schema_512 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ reference local typeNames_512 + } + } + else + utils.declaredType("Dynamic") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + + local function generateUnionType(schema: JsonSchema, typeNames: Type.TypeNames): Pair = +// ^^^^^^^^^^^^^^^^^ definition local generateUnionType_560 +// ^^^^^^ definition local schema_560 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ definition local typeNames_560 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + // If there are multiple types, the base schema has constraints that apply to each of the subtypes. + // We need to generate each one as its own type, with the constraints available on the schema. + if (schema.type is Listing) +// ^^^^^^ reference local schema_560 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + Pair( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). + // Force no further constraints to be added by passing on an empty json schema. + new JsonSchema {}, +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + new TypeNode.UnionTypeNode { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode# + members = new Listing { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/members. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + for (_type in (schema.type as Listing)) { +// ^^^^^ definition local _type_569 +// ^^^^^^ reference local schema_560 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + generateTypeNode((schema) { type = _type }, typeNames) +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^ reference local schema_560 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/type. +// ^^^^^ reference local _type_569 +// ^^^^^^^^^ reference local typeNames_560 + } + }.distinct +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#distinct. + } + ) + else + Pair( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). + (schema) { +// ^^^^^^ reference local schema_560 + oneOf = null +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/oneOf. + anyOf = null +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/anyOf. + }, + new TypeNode.UnionTypeNode { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode# + members = new Listing { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/members. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + when (schema.oneOf != null) { +// ^^^^^^ reference local schema_560 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/oneOf. + for (s in schema.oneOf!!) { +// ^ definition local s_584 +// ^^^^^^ reference local schema_560 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/oneOf. + generateTypeNode(s, typeNames) +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^ reference local s_584 +// ^^^^^^^^^ reference local typeNames_560 + } + } + // Not perfect; `anyOf` means that it can match one or more subschema. A union type is not the correct + // Pkl type. + when (schema.anyOf != null) { +// ^^^^^^ reference local schema_560 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/anyOf. + for (s in schema.anyOf!!) { +// ^ definition local s_591 +// ^^^^^^ reference local schema_560 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/anyOf. + generateTypeNode(s, typeNames) +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^ reference local s_591 +// ^^^^^^^^^ reference local typeNames_560 + } + } + }.distinct +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#distinct. + } + ) + + local function generateListingType(schema: JsonSchema, typeNames: Type.TypeNames): TypeNode = +// ^^^^^^^^^^^^^^^^^^^ definition local generateListingType_599 +// ^^^^^^ definition local schema_599 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ definition local typeNames_599 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + (utils.declaredType("Listing")) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + when (schema.items is JsonSchema) { +// ^^^^^^ reference local schema_599 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + typeArguments { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/typeArguments. + generateTypeNode(schema.items as JsonSchema, typeNames) +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^ reference local schema_599 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ reference local typeNames_599 + } + } + } + + /// Tells if the schema's `enum` or `const` values all satisfy the [predicate]. + /// + /// Used for determining the base type. + local function constOrEnumsMatch(schema: JsonSchema, predicate: (JsonSchema.JsonSchemaValue?) -> Boolean): Boolean = +// ^^^^^^^^^^^^^^^^^ definition local constOrEnumsMatch_608 +// documentation +// > Tells if the schema's `enum` or `const` values all satisfy the [`predicate`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/internal/TypesGenerator.pkl#L611,C54). +// > +// > Used for determining the base type. +// ^^^^^^ definition local schema_611 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ definition local predicate_611 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaValue# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + predicate.apply(schema.`const`) +// ^^^^^^^^^ reference local predicate_611 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^^ reference local schema_611 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/const. + || (schema.enum?.toList()?.every(predicate) ?? predicate.apply(schema.enum)) +// ^^^^^^ reference local schema_611 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^^^^^^^^ reference local predicate_611 +// ^^^^^^^^^ reference local predicate_611 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^^ reference local schema_611 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. + + /// Returns the name of the schema's type if there is only one type. + /// + /// For example, for these two schemas, `"string"` gets returned. + /// ``` + /// type = "string" + /// type { "string" } + /// ``` + /// + /// If [JsonSchema.type] is a listing with more than one type, [null] gets returned. + local function unwrappedSingularType(schema: JsonSchema): JsonSchema.JsonSchemaTypeName? = +// ^^^^^^^^^^^^^^^^^^^^^ definition local unwrappedSingularType_615 +// documentation +// > Returns the name of the schema's type if there is only one type. +// > +// > For example, for these two schemas, `"string"` gets returned. +// > ``` +// > type = "string" +// > type { "string" } +// > ``` +// > +// > If [`JsonSchema.type`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L222,C1) is a listing with more than one type, `null` gets returned. +// ^^^^^^ definition local schema_624 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaTypeName# + if (schema.type is Listing) +// ^^^^^^ reference local schema_624 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + if (schema.type.length == 1) schema.type.toList().first +// ^^^^^^ reference local schema_624 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#length. +// ^^^^^^ reference local schema_624 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. + else null + else + schema.type as JsonSchema.JsonSchemaTypeName? +// ^^^^^^ reference local schema_624 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaTypeName# + + /// Tells if the [schema] should be generated as [Number] or [Integer]. + local function isNumberSchema(schema: JsonSchema) = +// ^^^^^^^^^^^^^^ definition local isNumberSchema_631 +// documentation +// > Tells if the [`schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/internal/TypesGenerator.pkl#L632,C31) should be generated as [`Number`](pkl-lsp://stdlib/base.pkl#L585,C25) or `Integer`. +// ^^^^^^ definition local schema_632 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + let (type = unwrappedSingularType(schema)) +// ^^^^ definition local type_633 +// ^^^^^^^^^^^^^^^^^^^^^ reference local unwrappedSingularType_615 +// ^^^^^^ reference local schema_632 + type == "number" || type == "integer" || constOrEnumsMatch(schema, (elem) -> elem is Number) +// ^^^^ reference local type_633 +// ^^^^ reference local type_633 +// ^^^^^^^^^^^^^^^^^ reference local constOrEnumsMatch_608 +// ^^^^^^ reference local schema_632 +// ^^^^ definition local elem_634 +// ^^^^ reference local elem_634 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// Tells if the [schema] should be generated as a [String]. + local function isStringSchema(schema: JsonSchema) = +// ^^^^^^^^^^^^^^ definition local isStringSchema_636 +// documentation +// > Tells if the [`schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/internal/TypesGenerator.pkl#L637,C31) should be generated as a [`String`](pkl-lsp://stdlib/base.pkl#L1094,C16). +// ^^^^^^ definition local schema_637 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + let (type = unwrappedSingularType(schema)) +// ^^^^ definition local type_638 +// ^^^^^^^^^^^^^^^^^^^^^ reference local unwrappedSingularType_615 +// ^^^^^^ reference local schema_637 + type == "string" || constOrEnumsMatch(schema, (elem) -> elem is String) +// ^^^^ reference local type_638 +// ^^^^^^^^^^^^^^^^^ reference local constOrEnumsMatch_608 +// ^^^^^^ reference local schema_637 +// ^^^^ definition local elem_639 +// ^^^^ reference local elem_639 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Tells if the [schema] should be generated as a [Boolean]. + local function isBooleanSchema(schema: JsonSchema) = +// ^^^^^^^^^^^^^^^ definition local isBooleanSchema_641 +// documentation +// > Tells if the [`schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/internal/TypesGenerator.pkl#L642,C32) should be generated as a [`Boolean`](pkl-lsp://stdlib/base.pkl#L1058,C16). +// ^^^^^^ definition local schema_642 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + let (type = unwrappedSingularType(schema)) +// ^^^^ definition local type_643 +// ^^^^^^^^^^^^^^^^^^^^^ reference local unwrappedSingularType_615 +// ^^^^^^ reference local schema_642 + type == "boolean" || constOrEnumsMatch(schema, (elem) -> elem is Boolean) +// ^^^^ reference local type_643 +// ^^^^^^^^^^^^^^^^^ reference local constOrEnumsMatch_608 +// ^^^^^^ reference local schema_642 +// ^^^^ definition local elem_644 +// ^^^^ reference local elem_644 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Tells if the [schema] should be generated as a [Listing] + local function isListingSchema(schema: JsonSchema) = +// ^^^^^^^^^^^^^^^ definition local isListingSchema_646 +// documentation +// > Tells if the [`schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/internal/TypesGenerator.pkl#L647,C32) should be generated as a [`Listing`](pkl-lsp://stdlib/base.pkl#L1860,C7) +// ^^^^^^ definition local schema_647 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + let (type = unwrappedSingularType(schema)) +// ^^^^ definition local type_648 +// ^^^^^^^^^^^^^^^^^^^^^ reference local unwrappedSingularType_615 +// ^^^^^^ reference local schema_647 + type == "array" || schema.items != null +// ^^^^ reference local type_648 +// ^^^^^^ reference local schema_647 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. + + /// Tells if the [schema] should be generated as a [Mapping]. + local function isMappingSchema(schema: JsonSchema) = +// ^^^^^^^^^^^^^^^ definition local isMappingSchema_651 +// documentation +// > Tells if the [`schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/internal/TypesGenerator.pkl#L652,C32) should be generated as a [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7). +// ^^^^^^ definition local schema_652 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + let (type = unwrappedSingularType(schema)) +// ^^^^ definition local type_653 +// ^^^^^^^^^^^^^^^^^^^^^ reference local unwrappedSingularType_615 +// ^^^^^^ reference local schema_652 + type == "object" || schema.properties != null || schema.additionalProperties != null +// ^^^^ reference local type_653 +// ^^^^^^ reference local schema_652 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. +// ^^^^^^ reference local schema_652 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. + + /// Generates the basic declared type (Int, Float, etc). + /// + /// In some cases, the basic type returns a refined type based off constraints (e.g. UInt8). + /// If so, the returned [JsonSchema] has those matching constraints (minimum, exclusiveMinimum, etc) removed. + local function generateBaseType(schema: JsonSchema, typeNames: Type.TypeNames): Pair = +// ^^^^^^^^^^^^^^^^ definition local generateBaseType_656 +// documentation +// > Generates the basic declared type (Int, Float, etc). +// > +// > In some cases, the basic type returns a refined type based off constraints (e.g. UInt8). +// > If so, the returned [`JsonSchema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L22,C1) has those matching constraints (minimum, exclusiveMinimum, etc) removed. +// ^^^^^^ definition local schema_660 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ definition local typeNames_660 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/TypeNames# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + if (schema.oneOf != null || schema.anyOf != null || schema.type is Listing && schema.type.length > 1) +// ^^^^^^ reference local schema_660 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/oneOf. +// ^^^^^^ reference local schema_660 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/anyOf. +// ^^^^^^ reference local schema_660 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference local schema_660 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#length. + generateUnionType(schema, typeNames) +// ^^^^^^^^^^^^^^^^^ reference local generateUnionType_560 +// ^^^^^^ reference local schema_660 +// ^^^^^^^^^ reference local typeNames_660 + else if (isNumberSchema(schema)) +// ^^^^^^^^^^^^^^ reference local isNumberSchema_631 +// ^^^^^^ reference local schema_660 + generateNumberType(schema) +// ^^^^^^^^^^^^^^^^^^ reference local generateNumberType_445 +// ^^^^^^ reference local schema_660 + else if (isStringSchema(schema)) +// ^^^^^^^^^^^^^^ reference local isStringSchema_636 +// ^^^^^^ reference local schema_660 + generateStringType(schema) +// ^^^^^^^^^^^^^^^^^^ reference local generateStringType_488 +// ^^^^^^ reference local schema_660 + else if (isBooleanSchema(schema)) +// ^^^^^^^^^^^^^^^ reference local isBooleanSchema_641 +// ^^^^^^ reference local schema_660 + Pair(schema, utils.declaredType("Boolean")) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_660 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + else if (isListingSchema(schema)) +// ^^^^^^^^^^^^^^^ reference local isListingSchema_646 +// ^^^^^^ reference local schema_660 + Pair(schema, generateListingType(schema, typeNames)) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_660 +// ^^^^^^^^^^^^^^^^^^^ reference local generateListingType_599 +// ^^^^^^ reference local schema_660 +// ^^^^^^^^^ reference local typeNames_660 + else if (isMappingSchema(schema)) +// ^^^^^^^^^^^^^^^ reference local isMappingSchema_651 +// ^^^^^^ reference local schema_660 + Pair(schema, generateObjectType(schema, typeNames)) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_660 +// ^^^^^^^^^^^^^^^^^^ reference local generateObjectType_512 +// ^^^^^^ reference local schema_660 +// ^^^^^^^^^ reference local typeNames_660 + else if (schema.allOf != null) +// ^^^^^^ reference local schema_660 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/allOf. + let (collatedSchema = collateAllOf(schema)) +// ^^^^^^^^^^^^^^ definition local collatedSchema_674 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/collateAllOf(). +// ^^^^^^ reference local schema_660 + generateBaseType(collatedSchema, typeNames) +// ^^^^^^^^^^^^^^^^ reference local generateBaseType_656 +// ^^^^^^^^^^^^^^ reference local collatedSchema_674 +// ^^^^^^^^^ reference local typeNames_660 + else + Pair(schema, utils.declaredType("Any")) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local schema_660 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). + + local function allOfErr(msg: String) = throw("Unable to combine allOf elements into one schema: \(msg)") +// ^^^^^^^^ definition local allOfErr_679 +// ^^^ definition local msg_679 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference local msg_679 + + function collateAllOf(schema: JsonSchema(allOf != null)): JsonSchema = +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/collateAllOf(). +// ^^^^^^ definition local schema_681 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/allOf. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + schema.allOf.fold(schema, (res, rawElem) -> +// ^^^^^^ reference local schema_681 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/allOf. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#fold(). +// ^^^^^^ reference local schema_681 +// ^^^ definition local res_682 +// ^^^^^^^ definition local rawElem_682 + let (resolvedElem = if (rawElem is JsonSchema && rawElem.$$refUri != null) ref.resolveRef(baseUri, rawElem) else rawElem) +// ^^^^^^^^^^^^ definition local resolvedElem_683 +// ^^^^^^^ reference local rawElem_682 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ reference local rawElem_682 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$refUri. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/resolveRef(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/baseUri. +// ^^^^^^^ reference local rawElem_682 +// ^^^^^^^ reference local rawElem_682 + let (elem = if (resolvedElem is JsonSchema && resolvedElem.allOf != null) collateAllOf(resolvedElem) else resolvedElem) +// ^^^^ definition local elem_684 +// ^^^^^^^^^^^^ reference local resolvedElem_683 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^^^ reference local resolvedElem_683 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/allOf. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/collateAllOf(). +// ^^^^^^^^^^^^ reference local resolvedElem_683 +// ^^^^^^^^^^^^ reference local resolvedElem_683 + new JsonSchema { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + // metadata + title = collateInformation(elem.title, res.title) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/title. +// ^^^^^^^^^^^^^^^^^^ reference local collateInformation_800 +// ^^^^ reference local elem_684 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/title. +// ^^^ reference local res_682 + description = collateInformation(elem.description, res.description) +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/description. +// ^^^^^^^^^^^^^^^^^^ reference local collateInformation_800 +// ^^^^ reference local elem_684 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/description. +// ^^^ reference local res_682 + default = +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/default. + if (elem.default != null && res.default != null) let (_ = trace("Unable to combine allOf elements into one schema: dropping conflicting default")) res.default +// ^^^^ reference local elem_684 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/default. +// ^^^ reference local res_682 +// ^^^ reference local res_682 + else elem.default ?? res.default +// ^^^^ reference local elem_684 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/default. +// ^^^ reference local res_682 + examples = +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/examples. + if (elem.examples != null && res.examples != null) +// ^^^^ reference local elem_684 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/examples. +// ^^^ reference local res_682 + new { + when (elem.examples is Listing) { ...elem.examples as Listing } else { elem.examples } +// ^^^^ reference local elem_684 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/examples. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference local elem_684 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/examples. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference local elem_684 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/examples. + when (res.examples is Listing) { ...res.examples as Listing } else { res.examples } +// ^^^ reference local res_682 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference local res_682 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference local res_682 + } + else elem.examples ?? res.examples +// ^^^^ reference local elem_684 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/examples. +// ^^^ reference local res_682 + deprecated = +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/deprecated. + if (elem.deprecated == true && res.deprecated == true) true +// ^^^^ reference local elem_684 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/deprecated. +// ^^^ reference local res_682 + else null // if we have a mix of null/false/true, this is undeterminable + readOnly = collateMetadataBoolean(elem.readOnly, res.readOnly, "readOnly") +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/readOnly. +// ^^^^^^^^^^^^^^^^^^^^^^ reference local collateMetadataBoolean_804 +// ^^^^ reference local elem_684 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/readOnly. +// ^^^ reference local res_682 + writeOnly = collateMetadataBoolean(elem.writeOnly, res.writeOnly, "writeOnly") +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/writeOnly. +// ^^^^^^^^^^^^^^^^^^^^^^ reference local collateMetadataBoolean_804 +// ^^^^ reference local elem_684 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/writeOnly. +// ^^^ reference local res_682 + + // core + type = +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/type. + if (res.type != null && elem.type != null && res.type != elem.type) allOfErr("conflicting type") +// ^^^ reference local res_682 +// ^^^^ reference local elem_684 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^ reference local res_682 +// ^^^^ reference local elem_684 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^^^^^^ reference local allOfErr_679 + else elem.type ?? res.type +// ^^^^ reference local elem_684 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +// ^^^ reference local res_682 + `const` = +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/const. + if (res.`const` != null && elem.`const` != null && res.`const` != elem.`const`) allOfErr("conflicting const") +// ^^^ reference local res_682 +// ^^^^ reference local elem_684 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/const. +// ^^^ reference local res_682 +// ^^^^ reference local elem_684 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/const. +// ^^^^^^^^ reference local allOfErr_679 + else elem.`const` ?? res.`const` +// ^^^^ reference local elem_684 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/const. +// ^^^ reference local res_682 + + // number + multipleOf = +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/multipleOf. + if (elem.multipleOf != null && res.multipleOf != null) +// ^^^^ reference local elem_684 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. +// ^^^ reference local res_682 + if (elem.multipleOf is Int && res.multipleOf is Int) math.lcm(elem.multipleOf!! as Int, res.multipleOf!! as Int) +// ^^^^ reference local elem_684 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^ reference local res_682 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^ reference pkl . pkl 0.29.0 `pkl.math`/lcm(). +// ^^^^ reference local elem_684 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^ reference local res_682 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + else allOfErr("multiple non-integer multipleOf") +// ^^^^^^^^ reference local allOfErr_679 + else elem.multipleOf ?? res.multipleOf +// ^^^^ reference local elem_684 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. +// ^^^ reference local res_682 + minimum = collateMin(elem.minimum, res.minimum) +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/minimum. +// ^^^^^^^^^^ reference local collateMin_792 +// ^^^^ reference local elem_684 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minimum. +// ^^^ reference local res_682 + exclusiveMinimum = collateMin(elem.exclusiveMinimum, res.exclusiveMinimum) +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/exclusiveMinimum. +// ^^^^^^^^^^ reference local collateMin_792 +// ^^^^ reference local elem_684 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMinimum. +// ^^^ reference local res_682 + maximum = collateMax(elem.maximum, res.maximum) +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/maximum. +// ^^^^^^^^^^ reference local collateMax_796 +// ^^^^ reference local elem_684 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maximum. +// ^^^ reference local res_682 + exclusiveMaximum = collateMax(elem.exclusiveMaximum, res.exclusiveMaximum) +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/exclusiveMaximum. +// ^^^^^^^^^^ reference local collateMax_796 +// ^^^^ reference local elem_684 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMaximum. +// ^^^ reference local res_682 + + // string + pattern = +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/pattern. + if (elem.pattern != null && res.pattern != null) "(?:\(elem.pattern))|(?:\(res.pattern))" +// ^^^^ reference local elem_684 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/pattern. +// ^^^ reference local res_682 +// ^^^^ reference local elem_684 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/pattern. +// ^^^ reference local res_682 + else elem.pattern ?? res.pattern +// ^^^^ reference local elem_684 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/pattern. +// ^^^ reference local res_682 + minLength = collateMin(elem.minLength, res.minLength) as UInt? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/minLength. +// ^^^^^^^^^^ reference local collateMin_792 +// ^^^^ reference local elem_684 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minLength. +// ^^^ reference local res_682 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + maxLength = collateMax(elem.maxLength, res.maxLength) as UInt? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/maxLength. +// ^^^^^^^^^^ reference local collateMax_796 +// ^^^^ reference local elem_684 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxLength. +// ^^^ reference local res_682 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + format = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/format. + if (res.format != null && elem.format != null && res.format != elem.format) allOfErr("conflicting format") +// ^^^ reference local res_682 +// ^^^^ reference local elem_684 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/format. +// ^^^ reference local res_682 +// ^^^^ reference local elem_684 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/format. +// ^^^^^^^^ reference local allOfErr_679 + else elem.format ?? res.format +// ^^^^ reference local elem_684 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/format. +// ^^^ reference local res_682 + + // object + properties = collateProperties(elem.properties, res.properties) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/properties. +// ^^^^^^^^^^^^^^^^^ reference local collateProperties_772 +// ^^^^ reference local elem_684 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. +// ^^^ reference local res_682 + patternProperties = collateProperties(elem.patternProperties, res.patternProperties) +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/patternProperties. +// ^^^^^^^^^^^^^^^^^ reference local collateProperties_772 +// ^^^^ reference local elem_684 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/patternProperties. +// ^^^ reference local res_682 + additionalProperties = collateSchema(elem.additionalProperties, res.additionalProperties, "additionalProperties") +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/additionalProperties. +// ^^^^^^^^^^^^^ reference local collateSchema_785 +// ^^^^ reference local elem_684 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. +// ^^^ reference local res_682 + required = +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/required. + if (elem.required == null && res.required == null) null +// ^^^^ reference local elem_684 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/required. +// ^^^ reference local res_682 + else ((elem.required?.toSet() ?? Set()) + (res.required?.toSet() ?? Set())).toListing() +// ^^^^ reference local elem_684 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/required. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toSet(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). +// ^^^ reference local res_682 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#toListing(). + propertyNames = collateSchema(elem.propertyNames, res.propertyNames, "propertyNames") +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/propertyNames. +// ^^^^^^^^^^^^^ reference local collateSchema_785 +// ^^^^ reference local elem_684 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/propertyNames. +// ^^^ reference local res_682 + minProperties = collateMin(elem.minProperties, res.minProperties) as UInt? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/minProperties. +// ^^^^^^^^^^ reference local collateMin_792 +// ^^^^ reference local elem_684 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minProperties. +// ^^^ reference local res_682 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + maxProperties = collateMax(elem.maxProperties, res.maxProperties) as UInt? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/maxProperties. +// ^^^^^^^^^^ reference local collateMax_796 +// ^^^^ reference local elem_684 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxProperties. +// ^^^ reference local res_682 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + // array + items = +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/items. + if (elem.items == null && res.items == null) null +// ^^^^ reference local elem_684 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^ reference local res_682 + else if ((res.items == null) != (elem.items == null)) elem.items ?? res.items +// ^^^ reference local res_682 +// ^^^^ reference local elem_684 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^ reference local elem_684 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^ reference local res_682 + else if (res.items is JsonSchema && elem.items is JsonSchema) collateAllOf(new JsonSchema { allOf { res.items; elem.items as JsonSchema } }) +// ^^^ reference local res_682 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference local elem_684 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/collateAllOf(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/allOf. +// ^^^ reference local res_682 +// ^^^^ reference local elem_684 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + else allOfErr("conflicting items lhs:'\(elem.items)' rhs:'\(res.items)'") +// ^^^^^^^^ reference local allOfErr_679 +// ^^^^ reference local elem_684 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^ reference local res_682 + additionalItems = collateSchema(elem.additionalItems, res.additionalItems, "additionalItems") +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/additionalItems. +// ^^^^^^^^^^^^^ reference local collateSchema_785 +// ^^^^ reference local elem_684 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalItems. +// ^^^ reference local res_682 + minItems = collateMin(elem.minItems, res.minItems) as UInt? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/minItems. +// ^^^^^^^^^^ reference local collateMin_792 +// ^^^^ reference local elem_684 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minItems. +// ^^^ reference local res_682 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + maxItems = collateMax(elem.maxItems, res.maxItems) as UInt? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/maxItems. +// ^^^^^^^^^^ reference local collateMax_796 +// ^^^^ reference local elem_684 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxItems. +// ^^^ reference local res_682 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + uniqueItems = +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/uniqueItems. + if (elem.uniqueItems == true || res.uniqueItems == true) true +// ^^^^ reference local elem_684 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/uniqueItems. +// ^^^ reference local res_682 + else elem.uniqueItems ?? res.uniqueItems +// ^^^^ reference local elem_684 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/uniqueItems. +// ^^^ reference local res_682 + + // composition + oneOf = collateSet(elem.oneOf, res.oneOf) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/oneOf. +// ^^^^^^^^^^ reference local collateSet_765 +// ^^^^ reference local elem_684 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/oneOf. +// ^^^ reference local res_682 + anyOf = collateSet(elem.anyOf, res.anyOf) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/anyOf. +// ^^^^^^^^^^ reference local collateSet_765 +// ^^^^ reference local elem_684 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/anyOf. +// ^^^ reference local res_682 + not = collateSchema(elem.not, res.not, "not") +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/not. +// ^^^^^^^^^^^^^ reference local collateSchema_785 +// ^^^^ reference local elem_684 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/not. +// ^^^ reference local res_682 + } + ) + + local function collateSet(lhs: Listing(!isEmpty)?, rhs: Listing(!isEmpty)?): Listing(!isEmpty)? = +// ^^^^^^^^^^ definition local collateSet_765 +// ^^^ definition local lhs_765 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. +// ^^^ definition local rhs_765 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + if (lhs != null && rhs != null) +// ^^^ reference local lhs_765 +// ^^^ reference local rhs_765 + let (intersection = lhs.toSet().intersect(rhs.toSet())) +// ^^^^^^^^^^^^ definition local intersection_767 +// ^^^ reference local lhs_765 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toSet(). +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#intersect(). +// ^^^ reference local rhs_765 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toSet(). + if (intersection.isEmpty) allOfErr("conflicting oneOf") +// ^^^^^^^^^^^^ reference local intersection_767 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#isEmpty. +// ^^^^^^^^ reference local allOfErr_679 + else intersection.toListing() +// ^^^^^^^^^^^^ reference local intersection_767 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#toListing(). + else lhs ?? rhs +// ^^^ reference local lhs_765 +// ^^^ reference local rhs_765 + + local function collateProperties(lhs: Mapping?, rhs: Mapping?): Mapping? = +// ^^^^^^^^^^^^^^^^^ definition local collateProperties_772 +// ^^^ definition local lhs_772 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isRegex. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^ definition local rhs_772 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isRegex. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isRegex. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + if (lhs != null && rhs != null) +// ^^^ reference local lhs_772 +// ^^^ reference local rhs_772 + new { + for (key in lhs.keys + rhs.keys) { +// ^^^ definition local key_775 +// ^^^ reference local lhs_772 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#keys. +// ^^^ reference local rhs_772 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#keys. + when (lhs.containsKey(key) && rhs.containsKey(key)) { +// ^^^ reference local lhs_772 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). +// ^^^ reference local key_775 +// ^^^ reference local rhs_772 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). +// ^^^ reference local key_775 + [key] = collateAllOf(new JsonSchema { allOf { lhs[key]; rhs[key] } }) +// ^^^ reference local key_775 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/collateAllOf(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/allOf. +// ^^^ reference local lhs_772 +// ^^^ reference local key_775 +// ^^^ reference local rhs_772 +// ^^^ reference local key_775 + } else { + [key] = lhs.getOrNull(key) ?? rhs[key] +// ^^^ reference local key_775 +// ^^^ reference local lhs_772 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^ reference local key_775 +// ^^^ reference local rhs_772 +// ^^^ reference local key_775 + } + } + } + else lhs ?? rhs +// ^^^ reference local lhs_772 +// ^^^ reference local rhs_772 + + local function collateSchema(lhs: JsonSchema.Schema?, rhs: JsonSchema.Schema?, fieldName: String): JsonSchema.Schema? = +// ^^^^^^^^^^^^^ definition local collateSchema_785 +// ^^^ definition local lhs_785 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^ definition local rhs_785 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^^^ definition local fieldName_785 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + if (lhs != null && rhs != null) +// ^^^ reference local lhs_785 +// ^^^ reference local rhs_785 + if (lhs is Boolean && rhs is Boolean) lhs || rhs +// ^^^ reference local lhs_785 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^ reference local rhs_785 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^ reference local lhs_785 +// ^^^ reference local rhs_785 + else if (lhs is JsonSchema && rhs is JsonSchema) collateAllOf(new JsonSchema { allOf { lhs; rhs } }) +// ^^^ reference local lhs_785 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^ reference local rhs_785 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/collateAllOf(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/allOf. +// ^^^ reference local lhs_785 +// ^^^ reference local rhs_785 + else allOfErr("multiple non-JsonSchema \(fieldName)") +// ^^^^^^^^ reference local allOfErr_679 +// ^^^^^^^^^ reference local fieldName_785 + else lhs ?? rhs +// ^^^ reference local lhs_785 +// ^^^ reference local rhs_785 + + local function collateMin(lhs: Number?, rhs: Number?): Number? = +// ^^^^^^^^^^ definition local collateMin_792 +// ^^^ definition local lhs_792 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^ definition local rhs_792 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + if (lhs != null && rhs != null) math.max(lhs, rhs) +// ^^^ reference local lhs_792 +// ^^^ reference local rhs_792 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^ reference pkl . pkl 0.29.0 `pkl.math`/max(). +// ^^^ reference local lhs_792 +// ^^^ reference local rhs_792 + else lhs ?? rhs +// ^^^ reference local lhs_792 +// ^^^ reference local rhs_792 + + local function collateMax(lhs: Number?, rhs: Number?): Number? = +// ^^^^^^^^^^ definition local collateMax_796 +// ^^^ definition local lhs_796 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^ definition local rhs_796 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + if (lhs != null && rhs != null) math.min(lhs, rhs) +// ^^^ reference local lhs_796 +// ^^^ reference local rhs_796 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^ reference pkl . pkl 0.29.0 `pkl.math`/min(). +// ^^^ reference local lhs_796 +// ^^^ reference local rhs_796 + else lhs ?? rhs +// ^^^ reference local lhs_796 +// ^^^ reference local rhs_796 + + local function collateInformation(lhs: String?, rhs: String?): String? = +// ^^^^^^^^^^^^^^^^^^ definition local collateInformation_800 +// ^^^ definition local lhs_800 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local rhs_800 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (lhs != null && rhs != null) "\(lhs)\n----\n\(rhs)" +// ^^^ reference local lhs_800 +// ^^^ reference local rhs_800 +// ^^^ reference local lhs_800 +// ^^^ reference local rhs_800 + else lhs ?? rhs +// ^^^ reference local lhs_800 +// ^^^ reference local rhs_800 + + local function collateMetadataBoolean(lhs: Boolean?, rhs: Boolean?, fieldName: String): Boolean? = +// ^^^^^^^^^^^^^^^^^^^^^^ definition local collateMetadataBoolean_804 +// ^^^ definition local lhs_804 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^ definition local rhs_804 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^^ definition local fieldName_804 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + if (lhs != rhs) allOfErr("conflicting \(fieldName)") +// ^^^ reference local lhs_804 +// ^^^ reference local rhs_804 +// ^^^^^^^^ reference local allOfErr_679 +// ^^^^^^^^^ reference local fieldName_804 + else lhs +// ^^^ reference local lhs_804 + diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/internal/singularize.pkl b/pkl-pantrysnapshot/org.json_schema.contrib/internal/singularize.pkl new file mode 100755 index 00000000..0d1cdcc6 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/internal/singularize.pkl @@ -0,0 +1,313 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Logic for singularizing a word. + @Unlisted +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Unlisted# + module org.json_schema.contrib.internal.singularize +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/singularize.pkl`/ + + + // Adapted from + // + // Original license: + // The MIT License (MIT) + // Copyright (c) 2013 Blake Embrey (hello@blakeembrey.com) + // + // Permission is hereby granted, free of charge, to any person obtaining a copy + // of this software and associated documentation files (the "Software"), to deal + // in the Software without restriction, including without limitation the rights + // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + // copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions: + // + // The above copyright notice and this permission notice shall be included in + // all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + // THE SOFTWARE. + local ALWAYS_SINGLE_WORDS: Set = Set( +// ^^^^^^^^^^^^^^^^^^^ definition local ALWAYS_SINGLE_WORDS_44 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). + "adulthood", + "advice", + "agenda", + "aid", + "aircraft", + "alcohol", + "ammo", + "analytics", + "anime", + "athletics", + "audio", + "bison", + "blood", + "bream", + "buffalo", + "butter", + "carp", + "cash", + "chassis", + "chess", + "clothing", + "cod", + "commerce", + "cooperation", + "corps", + "debris", + "diabetes", + "digestion", + "elk", + "energy", + "equipment", + "excretion", + "expertise", + "firmware", + "flounder", + "fun", + "gallows", + "garbage", + "graffiti", + "hardware", + "headquarters", + "health", + "herpes", + "highjinks", + "homework", + "housework", + "information", + "jeans", + "justice", + "kudos", + "labour", + "literature", + "machinery", + "mackerel", + "mail", + "media", + "mews", + "moose", + "music", + "mud", + "manga", + "news", + "only", + "pants", + "personnel", + "pike", + "plankton", + "pliers", + "police", + "pollution", + "premises", + "rain", + "research", + "rice", + "salmon", + "scissors", + "series", + "sewage", + "shambles", + "sheep", + "shrimp", + "software", + "staff", + "swine", + "tennis", + "traffic", + "transportation", + "trousers", + "trout", + "tuna", + "wealth", + "welfare", + "whiting", + "wildebeest", + "wildlife", + "you" + ) + + local ALWAYS_SINGLE_WORDS_REG: Set = Set( +// ^^^^^^^^^^^^^^^^^^^^^^^ definition local ALWAYS_SINGLE_WORDS_REG_143 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). + Regex(#"pok[eé]mon$"#), +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + Regex(#"[^aeiou]ese$"#), // "chinese", "japanese" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + Regex(#"deer$"#), // "deer", "reindeer" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + Regex(#"fish$"#), // "fish", "blowfish", "angelfish" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + Regex(#"measles$"#), +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + Regex(#"o[iu]s$"#), // "carnivorous" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + Regex(#"pox$"#), // "chickpox", "smallpox" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + Regex(#"sheep$"#) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + ) + + local SINGULARIZATION_RULES: Mapping = new { +// ^^^^^^^^^^^^^^^^^^^^^ definition local SINGULARIZATION_RULES_154 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + [Regex(#"men$"#)] = "man" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(eau)x?$"#)] = "$1" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(child)ren$"#)] = "$1" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(pe)(rson|ople)$"#)] = "$1rson" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(matr|append)ices$"#)] = "$1ix" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(cod|mur|sil|vert|ind)ices$"#)] = "$1ex" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(alumn|alg|vertebr)ae$"#)] = "$1a" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$"#)] = "$1on" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$"#)] = "$1um" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$"#)] = "$1us" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(test)(?:is|es)$"#)] = "$1is" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(movie|twelve|abuse|e[mn]u)s$"#)] = "$1" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$"#)] = "$1sis" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$"#)] = "$1" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(seraph|cherub)im$"#)] = "$1" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"\b((?:tit)?m|l)ice$"#)] = "$1ouse" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"\b(mon|smil)ies$"#)] = "$1ey" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"\b(l|(?:neck|cross|hog|aun)?t|coll|faer|food|gen|goon|group|hipp|junk|vegg|(?:pork)?p|charl|calor|cut)ies$"#)] = "$1ie" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(dg|ss|ois|lk|ok|wn|mb|th|ch|ec|oal|is|ck|ix|sser|ts|wb)ies$"#)] = "$1ie" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"ies$"#)] = "y" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(ar|(?:wo|[ae])l|[eo][ao])ves$"#)] = "$1f" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$"#)] = "$1fe" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"(ss)$"#)] = "$1" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + [Regex(#"s$"#)] = "" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + } + + // Adapted from https://github.com/plurals/pluralize/blob/master/pluralize.js + // Original license: + // + // The MIT License (MIT) + // + // Copyright (c) 2013 Blake Embrey (hello@blakeembrey.com) + // + // Permission is hereby granted, free of charge, to any person obtaining a copy + // of this software and associated documentation files (the "Software"), to deal + // in the Software without restriction, including without limitation the rights + // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + // copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions: + // + // The above copyright notice and this permission notice shall be included in + // all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + // THE SOFTWARE. + /// Singularize (unpluralize) a word. + function singularize(word: String) = +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/singularize.pkl`/singularize(). +// documentation +// > Singularize (unpluralize) a word. +// ^^^^ definition local word_206 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (ALWAYS_SINGLE_WORDS.contains(word)) word +// ^^^^^^^^^^^^^^^^^^^ reference local ALWAYS_SINGLE_WORDS_44 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). +// ^^^^ reference local word_206 +// ^^^^ reference local word_206 + else if (ALWAYS_SINGLE_WORDS_REG.any((r) -> word.matches(r))) word +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local ALWAYS_SINGLE_WORDS_REG_143 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#any(). +// ^ definition local r_208 +// ^^^^ reference local word_206 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^ reference local r_208 +// ^^^^ reference local word_206 + else + SINGULARIZATION_RULES +// ^^^^^^^^^^^^^^^^^^^^^ reference local SINGULARIZATION_RULES_154 + .toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + .entries +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. + .fold(Pair(word, false), (pair: Pair, rule) -> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^ reference local word_206 +// ^^^^ definition local pair_213 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^ definition local rule_213 + // Track if we've hit one of the rules. Exit once a rule has been hit. + if (pair.second) +// ^^^^ reference local pair_213 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + pair +// ^^^^ reference local pair_213 + else + let (result = pair.first.replaceLast(rule.first, rule.second)) +// ^^^^^^ definition local result_218 +// ^^^^ reference local pair_213 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceLast(). +// ^^^^ reference local rule_213 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^^^^ reference local rule_213 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + Pair(result, result != pair.first) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^ reference local result_218 +// ^^^^^^ reference local result_218 +// ^^^^ reference local pair_213 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + ) + .first +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/internal/utils.pkl b/pkl-pantrysnapshot/org.json_schema.contrib/internal/utils.pkl new file mode 100755 index 00000000..725027a7 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/internal/utils.pkl @@ -0,0 +1,492 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.json_schema.contrib.internal.utils +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ + + import "@syntax/TypeNode.pkl" + import "@syntax/ExpressionNode.pkl" + import "@syntax/operators.pkl" + import "@syntax/AnnotationNode.pkl" + import "Type.pkl" + import "@jsonschema/JsonSchema.pkl" + + /// Renders the string in pascal case. + /// + /// Underscores, dashes and dots are all considered word separators. + /// + /// Facts: + /// ``` + /// pascalCase("foo-bar") == "FooBar" + /// pascalCase("foo.bar") == "FooBar" + /// pascalCase("foo_bar") == "FooBar" + /// pascalCase("fooBar") == "FooBar" + /// ``` + function pascalCase(text: String) = +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/pascalCase(). +// documentation +// > Renders the string in pascal case. +// > +// > Underscores, dashes and dots are all considered word separators. +// > +// > Facts: +// > ``` +// > pascalCase("foo-bar") == "FooBar" +// > pascalCase("foo.bar") == "FooBar" +// > pascalCase("foo_bar") == "FooBar" +// > pascalCase("fooBar") == "FooBar" +// > ``` +// ^^^^ definition local text_36 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (words = text.split(Regex(#"[_.-]"#))) +// ^^^^^ definition local words_37 +// ^^^^ reference local text_36 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + words.map((w) -> w.capitalize()).join("") +// ^^^^^ reference local words_37 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local w_38 +// ^ reference local w_38 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#capitalize(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + /// Node representing `this`. + THIS: ExpressionNode.BuiltInKeywordExpressionNode = new { keyword = "this" } +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/THIS. +//documentation +//> Node representing `this`. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BuiltInKeywordExpressionNode# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/keyword. + + /// Node representing `@Deprecated` + DEPRECATED: AnnotationNode = new { +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/DEPRECATED. +//documentation +//> Node representing `@Deprecated` +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/ + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/identifier. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/parts. + new { value = "Deprecated" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/value. + } + } + } + + /// Creates a node equivalent of a number + function numberLiteral(num: Number) = new ExpressionNode.LiteralValueExpressionNode { value = num } +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/numberLiteral(). +// documentation +// > Creates a node equivalent of a number +// ^^^ definition local num_53 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/value. +// ^^^ reference local num_53 + + /// Creates a declared type + function declaredType(type: String) = new TypeNode.DeclaredTypeNode { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType(). +// documentation +// > Creates a declared type +// ^^^^ definition local type_56 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/parts. + new { + value = type +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/value. +// ^^^^ reference local type_56 + } + } + } + } + + function declaredType1(type: Type, isImport: Boolean) = new TypeNode.DeclaredTypeNode { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/declaredType1(). +// ^^^^ definition local type_66 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ +// ^^^^^^^^ definition local isImport_66 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/parts. + when (isImport) { +// ^^^^^^^^ reference local isImport_66 + new { + value = type.moduleName.split(".").last +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/value. +// ^^^^ reference local type_66 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/moduleName. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + } + } + new { + value = type.name +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/value. +// ^^^^ reference local type_66 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/name. + } + } + } + } + + /// Helper for creating `ExpressionNode.BinaryOperatorExpressionNode` + function binaryOperatorNode( +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/binaryOperatorNode(). +// documentation +// > Helper for creating `ExpressionNode.BinaryOperatorExpressionNode` + _lhs: ExpressionNode, +// ^^^^ definition local _lhs_83 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + _operator: operators.BinaryOperator, +// ^^^^^^^^^ definition local _operator_84 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BinaryOperator# + _rhs: ExpressionNode +// ^^^^ definition local _rhs_85 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + ): ExpressionNode.BinaryOperatorExpressionNode = new { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = _lhs +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/lhs. +// ^^^^ reference local _lhs_83 + operator = _operator +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/operator. +// ^^^^^^^^^ reference local _operator_84 + rhs = _rhs +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/rhs. +// ^^^^ reference local _rhs_85 + } + + /// Merge multiple schemas into one schema document. + function mergeSchemas(baseSchema: JsonSchema, rest: List) = +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/mergeSchemas(). +// documentation +// > Merge multiple schemas into one schema document. +// ^^^^^^^^^^ definition local baseSchema_93 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition local rest_93 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + rest +// ^^^^ reference local rest_93 + .fold(baseSchema.toMap(), (aggregate: Map, schema: JsonSchema.Schema) -> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^^^^^^^^ reference local baseSchema_93 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). +// ^^^^^^^^^ definition local aggregate_95 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^ definition local schema_95 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + if (schema is Boolean) +// ^^^^^^ reference local schema_95 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + aggregate +// ^^^^^^^^^ reference local aggregate_95 + else + aggregate + schema.toMap().filter((_, value) -> value != null) +// ^^^^^^^^^ reference local aggregate_95 +// ^^^^^^ reference local schema_95 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^^ definition local value_99 +// ^^^^^ reference local value_99 + ) + .toTyped(JsonSchema.getClass()) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toTyped(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + + + local function findMatchingSchemasInMapping( +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition local findMatchingSchemasInMapping_104 + m: Mapping?, +// ^ definition local m_105 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + path: List, +// ^^^^ definition local path_106 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + predicate: (JsonSchema) -> Boolean +// ^^^^^^^^^ definition local predicate_107 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + ): Map, JsonSchema> = +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + if (m == null) +// ^ reference local m_105 + Map() +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + else + m +// ^ reference local m_105 + .toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + .filter((_, value) -> value is JsonSchema) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^^ definition local value_114 +// ^^^^^ reference local value_114 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + .flatMap((propertyName, schema) -> _findMatchingSubSchemas(schema as JsonSchema, path.add(propertyName), predicate)) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#flatMap(). +// ^^^^^^^^^^^^ definition local propertyName_115 +// ^^^^^^ definition local schema_115 +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). +// ^^^^^^ reference local schema_115 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference local path_106 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^^^^^^^^ reference local propertyName_115 +// ^^^^^^^^^ reference local predicate_107 + + local function findMatchingSchemasInListing( +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition local findMatchingSchemasInListing_117 + l: Listing?, +// ^ definition local l_118 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + path: List, +// ^^^^ definition local path_119 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + namePart: String, +// ^^^^^^^^ definition local namePart_120 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + predicate: (JsonSchema) -> Boolean +// ^^^^^^^^^ definition local predicate_121 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + ): Map, JsonSchema> = +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + if (l == null) +// ^ reference local l_118 + Map() +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + else + l.toList() +// ^ reference local l_118 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + .filterIsInstance(JsonSchema.getClass()) +// ^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterIsInstance(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + .mapIndexed((idx, schema) -> Pair(idx, schema)) +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#mapIndexed(). +// ^^^ definition local idx_128 +// ^^^^^^ definition local schema_128 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^ reference local idx_128 +// ^^^^^^ reference local schema_128 + .toMap((p) -> p.first, (p) -> p.second) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toMap(). +// ^ definition local p_129 +// ^ reference local p_129 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^ definition local p_129 +// ^ reference local p_129 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + .flatMap((idx, schema) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#flatMap(). +// ^^^ definition local idx_130 +// ^^^^^^ definition local schema_130 + _findMatchingSubSchemas( +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). + schema, +// ^^^^^^ reference local schema_130 + path.add((path.lastOrNull ?? "") + namePart + idx.toString()), +// ^^^^ reference local path_119 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^ reference local path_119 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#lastOrNull. +// ^^^^^^^^ reference local namePart_120 +// ^^^ reference local idx_130 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + predicate +// ^^^^^^^^^ reference local predicate_121 + ) + ) + + function _findMatchingSubSchemas( +// ^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). + schema: JsonSchema, +// ^^^^^^ definition local schema_139 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + path: List, +// ^^^^ definition local path_140 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + predicate: (JsonSchema) -> Boolean +// ^^^^^^^^^ definition local predicate_141 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + ): Map, JsonSchema> = +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + (if (predicate.apply(schema)) +// ^^^^^^^^^ reference local predicate_141 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^^ reference local schema_139 + Map(path, schema) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^ reference local path_140 +// ^^^^^^ reference local schema_139 + else + Map()) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + + findMatchingSchemasInMapping(schema.properties, path, predicate) +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local findMatchingSchemasInMapping_104 +// ^^^^^^ reference local schema_139 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. +// ^^^^ reference local path_140 +// ^^^^^^^^^ reference local predicate_141 + + ( + let (map = schema.patternProperties?.toMap() ?? Map()) +// ^^^ definition local map_149 +// ^^^^^^ reference local schema_139 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/patternProperties. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + if (map.length == 1 && map.values.first is JsonSchema) +// ^^^ reference local map_149 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#length. +// ^^^ reference local map_149 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + _findMatchingSubSchemas(map.values.first as JsonSchema, path, predicate) +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). +// ^^^ reference local map_149 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#values. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference local path_140 +// ^^^^^^^^^ reference local predicate_141 + else + Map() +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + ) + + findMatchingSchemasInMapping(schema.definitions, path, predicate) +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local findMatchingSchemasInMapping_104 +// ^^^^^^ reference local schema_139 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/definitions. +// ^^^^ reference local path_140 +// ^^^^^^^^^ reference local predicate_141 + + findMatchingSchemasInMapping(schema.$defs, path, predicate) +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local findMatchingSchemasInMapping_104 +// ^^^^^^ reference local schema_139 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$defs. +// ^^^^ reference local path_140 +// ^^^^^^^^^ reference local predicate_141 + + (if (schema.additionalProperties is JsonSchema) +// ^^^^^^ reference local schema_139 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + _findMatchingSubSchemas(schema.additionalProperties as JsonSchema, path, predicate) +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). +// ^^^^^^ reference local schema_139 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference local path_140 +// ^^^^^^^^^ reference local predicate_141 + else + Map()) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + + (if (schema.items is JsonSchema) +// ^^^^^^ reference local schema_139 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + _findMatchingSubSchemas(schema.items as JsonSchema, path.add("[]"), predicate) +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). +// ^^^^^^ reference local schema_139 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference local path_140 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^^^^^ reference local predicate_141 + else if (schema.items is Listing) +// ^^^^^^ reference local schema_139 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + findMatchingSchemasInListing(schema.items as Listing, path, "Item", predicate) +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local findMatchingSchemasInListing_117 +// ^^^^^^ reference local schema_139 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference local path_140 +// ^^^^^^^^^ reference local predicate_141 + else Map()) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + + findMatchingSchemasInListing(schema.oneOf, path, "Alternate", predicate) +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local findMatchingSchemasInListing_117 +// ^^^^^^ reference local schema_139 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/oneOf. +// ^^^^ reference local path_140 +// ^^^^^^^^^ reference local predicate_141 + + findMatchingSchemasInListing(schema.anyOf, path, "Alternate", predicate) +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local findMatchingSchemasInListing_117 +// ^^^^^^ reference local schema_139 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/anyOf. +// ^^^^ reference local path_140 +// ^^^^^^^^^ reference local predicate_141 + + findMatchingSchemasInMapping(schema._inline_, path, predicate) +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local findMatchingSchemasInMapping_104 +// ^^^^^^ reference local schema_139 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/_inline_. +// ^^^^ reference local path_140 +// ^^^^^^^^^ reference local predicate_141 + + /// Traverse the [schema], returning all schemas that match [predicate]. + /// + /// Returns a map whose key is the path to that schema, and value is the schema itself. + // TODO: additionalItems, allOf + function findMatchingSubschemas(schema: JsonSchema, predicate: (JsonSchema) -> Boolean): Map, JsonSchema> = +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/findMatchingSubschemas(). +// documentation +// > Traverse the [`schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/internal/utils.pkl#L174,C33), returning all schemas that match [`predicate`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/internal/utils.pkl#L174,C53). +// > +// > Returns a map whose key is the path to that schema, and value is the schema itself. +// ^^^^^^ definition local schema_174 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^ definition local predicate_174 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + _findMatchingSubSchemas(schema, List(), predicate) +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/_findMatchingSubSchemas(). +// ^^^^^^ reference local schema_174 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^^ reference local predicate_174 + diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/ref.pkl b/pkl-pantrysnapshot/org.json_schema.contrib/ref.pkl new file mode 100755 index 00000000..a8472f29 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/ref.pkl @@ -0,0 +1,333 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Tools to resolve JSON Schema references + @Unlisted +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Unlisted# + module org.json_schema.contrib.ref +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/ + + import "@jsonschema/JsonSchema.pkl" + import "@jsonschema/Parser.pkl" + import "internal/utils.pkl" + import "@uri/URI.pkl" + + /// Parse a json pointer into its constitutents. + local function parseJsonPointer(ref: String): List = +// ^^^^^^^^^^^^^^^^ definition local parseJsonPointer_25 +// documentation +// > Parse a json pointer into its constitutents. +// ^^^ definition local ref_26 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + ref +// ^^^ reference local ref_26 + .split("/") +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). + .map((str) -> str +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^ definition local str_29 +// ^^^ reference local str_29 + .replaceAll("~0", "~") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + .replaceAll("~1", "/")) +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + .map((it) -> URI.percentDecode(it)) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local it_32 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). +// ^^ reference local it_32 + .map((str) -> str.toIntOrNull() ?? str) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^ definition local str_33 +// ^^^ reference local str_33 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toIntOrNull(). +// ^^^ reference local str_33 + + local function resolveRefImpl(cursor: Any, parts: List, fullRef: URI): JsonSchema.Schema? = +// ^^^^^^^^^^^^^^ definition local resolveRefImpl_35 +// ^^^^^^ definition local cursor_35 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^ definition local parts_35 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^ definition local fullRef_35 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + if (cursor == null) +// ^^^^^^ reference local cursor_35 + let (_ = trace("WARN: failed to resolve $ref \(fullRef)")) +// ^^^^^^^ reference local fullRef_35 + null + else if (parts.isEmpty) +// ^^^^^ reference local parts_35 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + let (result = cursor as JsonSchema.Schema) +// ^^^^^^ definition local result_40 +// ^^^^^^ reference local cursor_35 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + // if the resolved schema is still a reference, resolve it again. + if (result is JsonSchema && result.$ref != null) +// ^^^^^^ reference local result_40 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^ reference local result_40 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$ref. + resolveRef(fullRef.basePath, result) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/resolveRef(). +// ^^^^^^^ reference local fullRef_35 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/basePath. +// ^^^^^^ reference local result_40 + else + result +// ^^^^^^ reference local result_40 + else + let (head = parts.first) +// ^^^^ definition local head_47 +// ^^^^^ reference local parts_35 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. + if (head is Int) +// ^^^^ reference local head_47 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + if (cursor is Listing) +// ^^^^^^ reference local cursor_35 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + resolveRefImpl(cursor[head], parts.drop(1), fullRef.basePath) +// ^^^^^^^^^^^^^^ reference local resolveRefImpl_35 +// ^^^^^^ reference local cursor_35 +// ^^^^ reference local head_47 +// ^^^^^ reference local parts_35 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^^^^^ reference local fullRef_35 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/basePath. + else + let (_ = trace("WARN: failed to read path `\(head)` from schema because it is not an array. Full ref: `\(fullRef)`")) +// ^^^^ reference local head_47 +// ^^^^^^^ reference local fullRef_35 + null + else if (cursor is JsonSchema) +// ^^^^^^ reference local cursor_35 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + if (cursor.hasProperty(head)) +// ^^^^^^ reference local cursor_35 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#hasProperty(). +// ^^^^ reference local head_47 + let (nextCursor = cursor.getPropertyOrNull(head) +// ^^^^^^^^^^ definition local nextCursor_56 +// ^^^^^^ reference local cursor_35 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#getPropertyOrNull(). +// ^^^^ reference local head_47 + ?? let (inline = cursor._inline_) if (inline != null) inline[head] else null) +// ^^^^^^ definition local inline_57 +// ^^^^^^ reference local cursor_35 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/_inline_. +// ^^^^^^ reference local inline_57 +// ^^^^^^ reference local inline_57 +// ^^^^ reference local head_47 + resolveRefImpl(nextCursor, parts.drop(1), fullRef) +// ^^^^^^^^^^^^^^ reference local resolveRefImpl_35 +// ^^^^^^^^^^ reference local nextCursor_56 +// ^^^^^ reference local parts_35 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^^^^^ reference local fullRef_35 + else + let (inline = cursor._inline_ ?? new Mapping {}) +// ^^^^^^ definition local inline_60 +// ^^^^^^ reference local cursor_35 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/_inline_. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + resolveRefImpl(inline.getOrNull(head), parts.drop(1), fullRef) +// ^^^^^^^^^^^^^^ reference local resolveRefImpl_35 +// ^^^^^^ reference local inline_60 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^ reference local head_47 +// ^^^^^ reference local parts_35 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^^^^^ reference local fullRef_35 + else if (cursor is Typed|Dynamic) +// ^^^^^^ reference local cursor_35 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + resolveRefImpl(cursor.getPropertyOrNull(head), parts.drop(1), fullRef) +// ^^^^^^^^^^^^^^ reference local resolveRefImpl_35 +// ^^^^^^ reference local cursor_35 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#getPropertyOrNull(). +// ^^^^ reference local head_47 +// ^^^^^ reference local parts_35 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^^^^^ reference local fullRef_35 + else if (cursor is Mapping) +// ^^^^^^ reference local cursor_35 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + resolveRefImpl(cursor[head], parts.drop(1), fullRef) +// ^^^^^^^^^^^^^^ reference local resolveRefImpl_35 +// ^^^^^^ reference local cursor_35 +// ^^^^ reference local head_47 +// ^^^^^ reference local parts_35 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^^^^^ reference local fullRef_35 + else + let (_ = trace("WARN: unable to find path \(head) in $ref \(fullRef). Tried to look in \(cursor)")) +// ^^^^ reference local head_47 +// ^^^^^^^ reference local fullRef_35 +// ^^^^^^ reference local cursor_35 + null + + local function isSameDocument(origin: URI, ref: URI) = +// ^^^^^^^^^^^^^^ definition local isSameDocument_70 +// ^^^^^^ definition local origin_70 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^ definition local ref_70 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + let (resolvedUri = origin.resolveUri(ref)) +// ^^^^^^^^^^^ definition local resolvedUri_71 +// ^^^^^^ reference local origin_70 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolveUri(). +// ^^^ reference local ref_70 + origin.scheme == resolvedUri.scheme +// ^^^^^^ reference local origin_70 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. +// ^^^^^^^^^^^ reference local resolvedUri_71 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. + && origin.authority() == resolvedUri.authority() +// ^^^^^^ reference local origin_70 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/authority(). +// ^^^^^^^^^^^ reference local resolvedUri_71 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/authority(). + && origin.path == resolvedUri.path +// ^^^^^^ reference local origin_70 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^^^^^^^ reference local resolvedUri_71 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. + + /// Resolve a [schema] which contains a [JsonSchema.`$ref`] against the [rootSchema]. + /// + /// [rootSchema] must be the root schema, and not a subschema. + /// [schema] must contain a `$ref`. + /// This is as forgiving as possible; if any of the parts fail, it simply returns null. + /// + /// The returned schema merges the resolved schema into [schema]. + function resolveRef(baseUri: URI, schema: JsonSchema): JsonSchema.Schema? = +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/resolveRef(). +// documentation +// > Resolve a [`schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/ref.pkl#L83,C35) which contains a `JsonSchema.`$ref`` against the `rootSchema`. +// > +// > `rootSchema` must be the root schema, and not a subschema. +// > [`schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/ref.pkl#L83,C35) must contain a `$ref`. +// > This is as forgiving as possible; if any of the parts fail, it simply returns null. +// > +// > The returned schema merges the resolved schema into [`schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema.contrib/ref.pkl#L83,C35). +// ^^^^^^^ definition local baseUri_83 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ definition local schema_83 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + let (ref = schema.$$refUri!!) +// ^^^ definition local ref_84 +// ^^^^^^ reference local schema_83 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$refUri. + let (parts = parseJsonPointer(ref.fragment ?? "")) +// ^^^^^ definition local parts_85 +// ^^^^^^^^^^^^^^^^ reference local parseJsonPointer_25 +// ^^^ reference local ref_84 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/fragment. + if (isSameDocument(baseUri, ref)) +// ^^^^^^^^^^^^^^ reference local isSameDocument_70 +// ^^^^^^^ reference local baseUri_83 +// ^^^ reference local ref_84 + resolveRefImpl(schema.$$baseSchema, parts.drop(1), ref) +// ^^^^^^^^^^^^^^ reference local resolveRefImpl_35 +// ^^^^^^ reference local schema_83 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$baseSchema. +// ^^^^^ reference local parts_85 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^ reference local ref_84 + .ifNonNull((it) -> +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_88 + (utils.mergeSchemas( +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/mergeSchemas(). + (schema) { $ref = null }, +// ^^^^^^ reference local schema_83 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/$ref. + List(it as JsonSchema.Schema) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^ reference local it_88 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + )) { + // store the original content of the referent for subsequent typeNames lookup in generateTypeNode + _inline_ { ["__ref_orig__"] = it } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/_inline_. +// ^^ reference local it_88 + } + ) + // Otherwise, we need to figure out the correct relative path. + // This is done by resolving [ref] against the base URI. + // If the resolved URI is a different document, it is read and parsed first. + else + let (resolvedUri = baseUri.resolveUri(ref)) +// ^^^^^^^^^^^ definition local resolvedUri_101 +// ^^^^^^^ reference local baseUri_83 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolveUri(). +// ^^^ reference local ref_84 + let (jsonSchemaBlob = read?(resolvedUri.basePath.toString())) +// ^^^^^^^^^^^^^^ definition local jsonSchemaBlob_102 +// ^^^^^^^^^^^ reference local resolvedUri_101 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/basePath. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + if (jsonSchemaBlob == null) +// ^^^^^^^^^^^^^^ reference local jsonSchemaBlob_102 + let (_ = trace("WARN: Failed to read external URI \(resolvedUri)")) +// ^^^^^^^^^^^ reference local resolvedUri_101 + null + else + let (parsedJsonSchema = (Parser.parse(jsonSchemaBlob)) { +// ^^^^^^^^^^^^^^^^ definition local parsedJsonSchema_107 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/parse(). +// ^^^^^^^^^^^^^^ reference local jsonSchemaBlob_102 + $$baseSchema = this +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/$$baseSchema. + }) + resolveRefImpl(parsedJsonSchema, parts.drop(1), ref) +// ^^^^^^^^^^^^^^ reference local resolveRefImpl_35 +// ^^^^^^^^^^^^^^^^ reference local parsedJsonSchema_107 +// ^^^^^ reference local parts_85 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^ reference local ref_84 + .ifNonNull((it) -> +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_111 + (utils.mergeSchemas( +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/utils.pkl`/mergeSchemas(). + (schema) { $ref = null }, +// ^^^^^^ reference local schema_83 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/$ref. + List(it as JsonSchema.Schema) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^ reference local it_111 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + )) { + // store the original content of the referent for subsequent typeNames lookup in generateTypeNode + _inline_ { ["__ref_orig__"] = it } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/_inline_. +// ^^ reference local it_111 + } + ) diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/tests/ModuleGenerator.pkl b/pkl-pantrysnapshot/org.json_schema.contrib/tests/ModuleGenerator.pkl new file mode 100755 index 00000000..5c085061 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/tests/ModuleGenerator.pkl @@ -0,0 +1,761 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.json_schema.contrib.tests.ModuleGenerator +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/ + + amends "pkl:test" + + import "@jsonschema/JsonSchema.pkl" + import "@jsonschema/Parser.pkl" + import "../internal/ModuleGenerator.pkl" + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/examples. + ["basic"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_26 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + ["bar"] { + type = "number" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + new ModuleGenerator { +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ + rootSchema = schema +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_26 + moduleName = "com.Example" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. + }.moduleNode.render("") +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["required properties"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_44 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + ["bar"] { + type = "number" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + required { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/required. + "foo" + "bar" + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_44 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["deprecated properties"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_63 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + deprecated = true +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/deprecated. + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_63 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["doc comments"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_76 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + title = "FooBar" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/title. + description = "FooBars when foo can bar" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/description. + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + title = "The fooiest of foos" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/title. + description = "The name of the foo that is really foo-like" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/description. + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_76 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["classes within properties"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_92 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + title = "FooBar" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/title. + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["bar"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_92 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["classes in nested properties"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_108 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["bar"] { + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["baz"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + } + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_108 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["classes in nested additionalProperties"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_129 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + additionalProperties { +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + oneOf { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/oneOf. + new JsonSchema { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["bar"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + new JsonSchema { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["baz"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + } + } + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_129 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["classes in nested patternProperties"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_157 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + patternProperties { +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/patternProperties. + ["[a-z]+"] { + oneOf { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/oneOf. + new JsonSchema { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["bar"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + new JsonSchema { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["baz"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + } + } + } + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_157 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["classes in listings"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_188 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foos"] { + type = "array" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + items { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/items. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["bar"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_188 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["classes in definitions"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_206 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + local self = this +// ^^^^ definition local self_207 + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + $ref = "#/definitions/foo" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$ref. + $$baseSchema = self +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$$baseSchema. +// ^^^^ reference local self_207 + } + } + definitions { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/definitions. + ["foo"] { + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["bar"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_206 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["classes within definitions properties"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_228 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + local self = this +// ^^^^ definition local self_229 + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + $ref = "#/definitions/foo" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$ref. + $$baseSchema = self +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$$baseSchema. +// ^^^^ reference local self_229 + } + ["bar"] { + $ref = "#/definitions/bar" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$ref. + $$baseSchema = self +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$$baseSchema. +// ^^^^ reference local self_229 + } + } + definitions { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/definitions. + ["foo"] { + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["waldo"] { + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["qux"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + } + } + ["bar"] { + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["waldo"] { + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["corge"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + } + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_228 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["classes from inline positions"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_269 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + local self = this +// ^^^^ definition local self_270 + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + $ref = "#/definitions/foo/myfoo" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$ref. + $$baseSchema = self +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$$baseSchema. +// ^^^^ reference local self_270 + } + } + definitions { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/definitions. + ["foo"] { + _inline_ { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/_inline_. + ["myfoo"] = new JsonSchema { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + title = "The fooiest of foos" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/title. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["bar"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + } + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_269 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["typealiases in definitions"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_296 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + local self = this +// ^^^^ definition local self_297 + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + $ref = "#/definitions/foo" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$ref. + $$baseSchema = self +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$$baseSchema. +// ^^^^ reference local self_297 + } + } + definitions { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/definitions. + ["foo"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + minLength = 5 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/minLength. + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_296 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["typealiases in $defs"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_315 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + local self = this +// ^^^^ definition local self_316 + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + $ref = "#/$defs/foo" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$ref. + $$baseSchema = self +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$$baseSchema. +// ^^^^ reference local self_316 + } + } + $defs { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$defs. + ["foo"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + minLength = 5 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/minLength. + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_315 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["typealiases in subschema definitions"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_334 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + local self = this +// ^^^^ definition local self_335 + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["bar"] { + $ref = "#/properties/foo/definitions/bar" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$ref. + $$baseSchema = self +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/$$baseSchema. +// ^^^^ reference local self_335 + } + } + definitions { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/definitions. + ["bar"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_334 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["root schemas that are not objects"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_357 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "array" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + items { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/items. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["foo"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_357 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["allOf"] { + local schema = Parser.parse(read("fixtures/test_allOf.json")) as JsonSchema +// ^^^^^^ definition local schema_371 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/parse(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_371 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["conflicts"] { + local schema = Parser.parse(read("fixtures/test_conflicts.json")) as JsonSchema +// ^^^^^^ definition local schema_375 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/parse(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.render("") +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_375 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). + } + ["name conflicts with built-in class name"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_379 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["int"] { + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["res1"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + } + ["boolean"] { + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["res2"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + } + ["mapping"] { + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["res3"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + } + ["listing"] { + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["res4"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + } + ["dynamic"] { + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["res5"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + } + ["null"] { + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/properties. + ["res6"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/type. + } + } + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/additionalProperties. + } + } + } + new ModuleGenerator { rootSchema = schema; moduleName = "com.Example" }.moduleNode.output.text +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/ +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/rootSchema. +// ^^^^^^ reference local schema_379 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ModuleGenerator.pkl`/moduleName. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/ModuleGenerator.pkl`/moduleNode. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/tests/TypesGenerator.pkl b/pkl-pantrysnapshot/org.json_schema.contrib/tests/TypesGenerator.pkl new file mode 100755 index 00000000..f756ec92 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/tests/TypesGenerator.pkl @@ -0,0 +1,538 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.json_schema.contrib.tests.TypesGenerator +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/ + + amends "pkl:test" + + import "@jsonschema/JsonSchema.pkl" + import "../internal/TypesGenerator.pkl" + import "../internal/Type.pkl" + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/examples. + ["numbers"] { + local numberSchema: JsonSchema = new { type = "number" } +// ^^^^^^^^^^^^ definition local numberSchema_26 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + TypesGenerator.generateTypeNode(numberSchema, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local numberSchema_26 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((numberSchema) { minimum = 5; maximum = 10 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local numberSchema_26 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minimum. +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/maximum. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((numberSchema) { maximum = 5 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local numberSchema_26 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/maximum. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((numberSchema) { exclusiveMinimum = 5 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local numberSchema_26 +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/exclusiveMinimum. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((numberSchema) { exclusiveMaximum = 5 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local numberSchema_26 +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/exclusiveMaximum. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((numberSchema) { multipleOf = 5 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local numberSchema_26 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/multipleOf. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((numberSchema) { minimum = 0 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local numberSchema_26 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minimum. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((numberSchema) { exclusiveMinimum = -1 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local numberSchema_26 +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/exclusiveMinimum. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((numberSchema) { multipleOf = 1 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local numberSchema_26 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/multipleOf. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((numberSchema) { minimum = 0; maximum = 255; multipleOf = 1 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local numberSchema_26 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minimum. +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/maximum. +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/multipleOf. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["number literals"] { + TypesGenerator.generateTypeNode(new JsonSchema { `const` = 5 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/const. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(new JsonSchema { enum = new Listing { 5; 6; 7 } }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/enum. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["strings"] { + local stringSchema: JsonSchema = new { +// ^^^^^^^^^^^^ definition local stringSchema_43 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + } + TypesGenerator.generateTypeNode(stringSchema, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local stringSchema_43 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((stringSchema) { minLength = 1 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local stringSchema_43 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((stringSchema) { minLength = 5 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local stringSchema_43 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((stringSchema) { maxLength = 10 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local stringSchema_43 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/maxLength. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((stringSchema) { minLength = 5; maxLength = 10 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local stringSchema_43 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/maxLength. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((stringSchema) { pattern = "[a-z]" }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local stringSchema_43 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/pattern. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((stringSchema) { format = "uri" }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local stringSchema_43 +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/format. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((stringSchema) { format = "regex" }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^^ reference local stringSchema_43 +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/format. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["string literals"] { + TypesGenerator.generateTypeNode(new JsonSchema { type = "string"; `const` = "Hello" }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/const. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(new JsonSchema { `const` = "Hello" }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/const. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(new JsonSchema { enum = new Listing { "Bart"; "Lisa" } }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/enum. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["booleans"] { + TypesGenerator.generateTypeNode(new JsonSchema { type = "boolean" }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["boolean literals"] { + TypesGenerator.generateTypeNode(new JsonSchema { `const` = true }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/const. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(new JsonSchema { `const` = false }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/const. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(new JsonSchema { enum = new Listing { false } }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/enum. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(new JsonSchema { enum = new Listing { true; false } }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/enum. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["arrays"] { + local arraySchema: JsonSchema = new { +// ^^^^^^^^^^^ definition local arraySchema_70 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "array" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + } + TypesGenerator.generateTypeNode((arraySchema) { minLength = 5 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^ reference local arraySchema_70 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((arraySchema) { maxLength = 10 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^ reference local arraySchema_70 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/maxLength. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((arraySchema) { minLength = 5; maxLength = 10 }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^ reference local arraySchema_70 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/maxLength. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((arraySchema) { uniqueItems = true }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^ reference local arraySchema_70 +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/uniqueItems. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((arraySchema) { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^ reference local arraySchema_70 + items { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/items. + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + } + }, Map()).render("") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode((arraySchema) { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^^ reference local arraySchema_70 + items { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/items. + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + minLength = 1 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. + } + }, Map()).render("") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["mappings"] { + TypesGenerator.generateTypeNode(new JsonSchema { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + additionalProperties { +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/additionalProperties. + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + } + }, Map()).render("") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(new JsonSchema { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + patternProperties { +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/patternProperties. + ["[a-z]"] { + type = "number" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + } + } + }, Map()).render("") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["nullables"] { + TypesGenerator.generateTypeNode(new JsonSchema { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = new Listing { "string"; "null" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + minLength = 10 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. + }, Map()).render("") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(new JsonSchema { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = new Listing { "string"; "number"; "null" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + minLength = 10 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. + minimum = 10 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minimum. + }, Map()).render("") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["unions"] { + TypesGenerator.generateTypeNode(new JsonSchema { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + oneOf { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/oneOf. + new JsonSchema { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + minLength = 5 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. + } + new JsonSchema { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "number" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + multipleOf = 10 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/multipleOf. + } + } + }, Map()).render("") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(new JsonSchema { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = new Listing { "string"; "number" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + minLength = 5 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. + multipleOf = 10 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/multipleOf. + }, Map()).render("") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["not"] { + TypesGenerator.generateTypeNode(new JsonSchema { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + not { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/not. + `const` = "foo" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/const. + } + }, Map()).render("") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(new JsonSchema { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + not { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/not. + minLength = 5 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. + maxLength = 10 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/maxLength. + } + }, Map()).render("") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["allOf"] { + TypesGenerator.generateTypeNode(new JsonSchema { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/type. + allOf { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/allOf. + new JsonSchema { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + minLength = 5 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. + } + new JsonSchema { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + maxLength = 10 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/maxLength. + } + } + }, Map()).render("") +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["types from $ref"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_164 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + local self = this +// ^^^^ definition local self_165 + $$baseSchema = this +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/$$baseSchema. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/properties. + ["bar"] { + $ref = "#/definitions/foo" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/$ref. + $$baseSchema = self +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/$$baseSchema. +// ^^^^ reference local self_165 + } + } + definitions { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/definitions. + ["foo"] { + minLength = 5 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/minLength. + } + } + } + // $ref's get resolved from the root schema. For this test, a root schema gets set up and the child property + // "properties.bar" has its type generated. + new TypesGenerator { enclosingModuleName = "TheFoo" } +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/enclosingModuleName. + .generateTypeNode(schema.properties!!["bar"], Map(schema.definitions!!["foo"] as JsonSchema, new Type { name = "Foo"; moduleName = "TheFoo" })) +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^ reference local schema_164 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference local schema_164 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/definitions. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/Type.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/name. +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/moduleName. + .render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(new JsonSchema { $ref = "#/not/resolveable"; $$baseSchema = schema }, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/$ref. +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/TypesGenerator.pkl`/$$baseSchema. +// ^^^^^^ reference local schema_164 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + ["boolean schemas"] { + TypesGenerator.generateTypeNode(true, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + TypesGenerator.generateTypeNode(false, Map()).render("") +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `internal/TypesGenerator.pkl`/generateTypeNode(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + } + diff --git a/pkl-pantrysnapshot/org.json_schema.contrib/tests/ref.pkl b/pkl-pantrysnapshot/org.json_schema.contrib/tests/ref.pkl new file mode 100755 index 00000000..85fa192c --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema.contrib/tests/ref.pkl @@ -0,0 +1,148 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.json_schema.contrib.tests.ref +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/ + + amends "pkl:test" + + import "@jsonschema/JsonSchema.pkl" + import "@uri/URI.pkl" + import "../ref.pkl" + + local function stripRefOrig(schema: JsonSchema.Schema?): JsonSchema.Schema? = +// ^^^^^^^^^^^^ definition local stripRefOrig_24 +// ^^^^^^ definition local schema_24 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + schema.ifNonNull((it) -> (it as JsonSchema.Schema) { +// ^^^^^^ reference local schema_24 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_25 +// ^^ reference local it_25 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + local newInline = super._inline_.toMap().remove("__ref_orig__").toMapping() +// ^^^^^^^^^ definition local newInline_26 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/_inline_. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#remove(). +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMapping(). + _inline_ = if (newInline.isEmpty) null else newInline +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/_inline_. +// ^^^^^^^^^ reference local newInline_26 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#isEmpty. +// ^^^^^^^^^ reference local newInline_26 + }) + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/facts. + ["resolveRef()"] { + local schema: JsonSchema = new { +// ^^^^^^ definition local schema_32 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/properties. + ["foo"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/type. + } + } + definitions { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/definitions. + ["bar"] { + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/properties. + ["baz"] { + title = "This is a baz" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/title. + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/type. + } + } + _inline_ { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/_inline_. + ["bizzy"] { + type = "array" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/type. + } + } + } + } + } + stripRefOrig(ref.resolveRef(new URI {}, new JsonSchema { $ref = "#/definitions/bar"; $$baseSchema = schema })) == schema.definitions!!["bar"] +// ^^^^^^^^^^^^ reference local stripRefOrig_24 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/resolveRef(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/$ref. +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/$$baseSchema. +// ^^^^^^ reference local schema_32 +// ^^^^^^ reference local schema_32 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/definitions. + stripRefOrig(ref.resolveRef(new URI {}, new JsonSchema { $ref = "#/definitions/bar/properties/baz"; $$baseSchema = schema })) == schema.definitions!!["bar"].properties!!["baz"] +// ^^^^^^^^^^^^ reference local stripRefOrig_24 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/resolveRef(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/$ref. +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/$$baseSchema. +// ^^^^^^ reference local schema_32 +// ^^^^^^ reference local schema_32 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/definitions. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + stripRefOrig(ref.resolveRef(new URI {}, new JsonSchema { $ref = "#/properties/foo"; $$baseSchema = schema })) == schema.properties!!["foo"] +// ^^^^^^^^^^^^ reference local stripRefOrig_24 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/resolveRef(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/$ref. +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/$$baseSchema. +// ^^^^^^ reference local schema_32 +// ^^^^^^ reference local schema_32 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. + stripRefOrig(ref.resolveRef(new URI {}, new JsonSchema { $ref = "#/definitions/bar/bizzy"; $$baseSchema = schema })) == schema.definitions!!["bar"]._inline_!!["bizzy"] +// ^^^^^^^^^^^^ reference local stripRefOrig_24 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/resolveRef(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/$ref. +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/$$baseSchema. +// ^^^^^^ reference local schema_32 +// ^^^^^^ reference local schema_32 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/definitions. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/_inline_. + stripRefOrig(ref.resolveRef(new URI {}, new JsonSchema { description = "This is a bizzy"; $ref = "#/definitions/bar/bizzy"; $$baseSchema = schema })) == new JsonSchema { +// ^^^^^^^^^^^^ reference local stripRefOrig_24 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `ref.pkl`/resolveRef(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/description. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/$ref. +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/$$baseSchema. +// ^^^^^^ reference local schema_32 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + description = "This is a bizzy" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/description. + type = "array" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib 1.1.5 `tests/ref.pkl`/type. + } + } + } + diff --git a/pkl-pantrysnapshot/org.json_schema/JsonSchema.pkl b/pkl-pantrysnapshot/org.json_schema/JsonSchema.pkl new file mode 100755 index 00000000..dd59e286 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema/JsonSchema.pkl @@ -0,0 +1,1044 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A document that describes constraints on JSON values. + /// + /// Currently only supports JSON Schema 6 or higher. + /// JSON Schema 4 isn't supported because of breaking changes in how [exclusiveMinimum] and [exclusiveMaximum] work. + /// + /// JSON Schema documentation can be found at . + open module org.json_schema.JsonSchema +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + + import "pkl:reflect" + import "JsonSchema.pkl" + import "@uri/URI.pkl" + + typealias JsonSchemaTypeName = "string"|"number"|"integer"|"boolean"|"object"|"array"|"null" +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaTypeName# + + typealias JsonSchemaVersion = +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaVersion# + "http://json-schema.org/draft-06/schema#" + |"http://json-schema.org/draft-06/schema" + |"http://json-schema.org/draft-07/schema#" + |"http://json-schema.org/draft-07/schema" + |"https://json-schema.org/draft/2019-09/schema" + |"https://json-schema.org/draft/2020-12/schema" + |String +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + typealias JsonSchemaValue = Boolean|Number|Null|String|Dynamic|Typed|Listing|Mapping +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaValue# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + + /// A JSON Schema can either be a [JsonSchema] object or a simple boolean. + /// + /// A boolean schema is shorthand for: + /// - true: Any value is valid + /// - false: No value is valid + typealias Schema = *JsonSchema|Boolean +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// documentation +// > A JSON Schema can either be a [`JsonSchema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L22,C1) object or a simple boolean. +// > +// > A boolean schema is shorthand for: +// > - true: Any value is valid +// > - false: No value is valid +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The known versions of JSON Schema. + /// + /// For example, `http://json-schema.org/draft-06/schema#`. + hidden versions: List = +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/versions. +// documentation +// > The known versions of JSON Schema. +// > +// > For example, `http://json-schema.org/draft-06/schema#`. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + (reflect.TypeAlias(JsonSchemaVersion).referent as reflect.UnionType).members +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias(). +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaVersion# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType#members. + .filterIsInstance(reflect.StringLiteralType) +// ^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterIsInstance(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType# + .map((it) -> it.value) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local it_54 +// ^^ reference local it_54 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType#value. + + /// Ensures that this document's [`$schema`] is later than [version]. + local function availableAfter(version: JsonSchemaVersion) = +// ^^^^^^^^^^^^^^ definition local availableAfter_56 +// documentation +// > Ensures that this document's ``$schema`` is later than [`version`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L57,C31). +// ^^^^^^^ definition local version_57 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaVersion# + if ($schema == null) // If $schema is unset, skip this check. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$schema. + true + else + let (currentVersion = versions.indexOfOrNull($schema)) +// ^^^^^^^^^^^^^^ definition local currentVersion_61 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/versions. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#indexOfOrNull(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$schema. + let (availableAfterVersion = versions.indexOf(version)) +// ^^^^^^^^^^^^^^^^^^^^^ definition local availableAfterVersion_62 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/versions. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#indexOf(). +// ^^^^^^^ reference local version_57 + if (currentVersion == null) +// ^^^^^^^^^^^^^^ reference local currentVersion_61 + let (_ = trace("WARN: unrecognized $schema: \($schema)")) true +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$schema. + else + currentVersion >= availableAfterVersion +// ^^^^^^^^^^^^^^ reference local currentVersion_61 +// ^^^^^^^^^^^^^^^^^^^^^ reference local availableAfterVersion_62 + + local parseUri = (it) -> URI.parse(it) +// ^^^^^^^^ definition local parseUri_68 +// ^^ definition local it_68 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^ reference local it_68 + + /// The base-level schema. + /// + /// This is a utility property to help with resolving references. + hidden $$baseSchema: JsonSchema? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$baseSchema. +// documentation +// > The base-level schema. +// > +// > This is a utility property to help with resolving references. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + + /// The ID as an instance of [URI]. + hidden /** final */ $$idUri: URI? = $id?.ifNonNull(parseUri) +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$idUri. +// documentation +// > The ID as an instance of [`URI`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.uri/URI.pkl#L21,C1). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$id. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^^^^^^^ reference local parseUri_68 + + /// The reference as an instance of [URI]. + hidden /** final */ $$refUri: URI? = $ref?.ifNonNull(parseUri) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$$refUri. +// documentation +// > The reference as an instance of [`URI`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.uri/URI.pkl#L21,C1). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$ref. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^^^^^^^ reference local parseUri_68 + + // region Core + /// URI-reference for the schema. + /// + /// The reference serves two purposes: + /// + /// * It declares a unique identifier for the schema. + /// * It declares a base URI against which `$ref` URI-references are resolved. + /// + /// It is best practice that every top-level schema should set `$id` to an + /// absolute-URI (not a relative reference), with a domain that you control. + /// + /// + $id: String? +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$id. +//documentation +//> URI-reference for the schema. +//> +//> The reference serves two purposes: +//> +//> * It declares a unique identifier for the schema. +//> * It declares a base URI against which `$ref` URI-references are resolved. +//> +//> It is best practice that every top-level schema should set `$id` to an +//> absolute-URI (not a relative reference), with a domain that you control. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Reference to a schema. + /// + /// + $ref: String? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$ref. +//documentation +//> Reference to a schema. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The presence of this property declares that this object represents a JSON Schema, and also + /// represents the version that the schema was written against. + /// + /// It is recommended that all JSON Schemas have a [`$schema`] entry, + /// which must be at the root. Therefore most of the time, you'll want + /// this at the root of your schema: + /// + /// "$schema": "http://json-schema.org/draft/2019-09/schema#" + /// + /// + $schema: JsonSchemaVersion? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$schema. +//documentation +//> The presence of this property declares that this object represents a JSON Schema, and also +//> represents the version that the schema was written against. +//> +//> It is recommended that all JSON Schemas have a ``$schema`` entry, +//> which must be at the root. Therefore most of the time, you'll want +//> this at the root of your schema: +//> +//> "$schema": "http://json-schema.org/draft/2019-09/schema#" +//> +//> +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaVersion# + + /// Implementation comments for a schema. + /// + /// Its value must always be a string. Unlike the annotations + /// [title], [description], and [examples], JSON schema + /// implementations aren't allowed to attach any meaning or behavior to it + /// whatsoever, and may even strip them at any time. Therefore, they are + /// useful for leaving notes to future editors of a JSON schema, but + /// should not be used to communicate to users of the schema. + /// + /// + $comment: String(availableAfter("http://json-schema.org/draft-07/schema#"))? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$comment. +//documentation +//> Implementation comments for a schema. +//> +//> Its value must always be a string. Unlike the annotations +//> [`title`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L142,C1), [`description`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L147,C1), and [`examples`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L174,C1), JSON schema +//> implementations aren't allowed to attach any meaning or behavior to it +//> whatsoever, and may even strip them at any time. Therefore, they are +//> useful for leaving notes to future editors of a JSON schema, but +//> should not be used to communicate to users of the schema. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^ reference local availableAfter_56 + + /// Defines schemas that maybe re-used within a complex JSON Schema document. + /// + /// + definitions: Mapping? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/definitions. +//documentation +//> Defines schemas that maybe re-used within a complex JSON Schema document. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// Defines schemas that maybe re-used within a complex JSON Schema document. + /// + /// This is the same thing as [definitions], but was renamed in draft 2019. + /// + /// + $defs: Mapping(availableAfter("https://json-schema.org/draft/2019-09/schema"))? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/$defs. +//documentation +//> Defines schemas that maybe re-used within a complex JSON Schema document. +//> +//> This is the same thing as [`definitions`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L127,C1), but was renamed in draft 2019. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^^^^^^^^ reference local availableAfter_56 + + // endregion + // region Metadata + + /// A short descriptor of this schema. + /// + /// + title: String? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/title. +//documentation +//> A short descriptor of this schema. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A long descriptor of this schema. + /// + /// + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/description. +//documentation +//> A long descriptor of this schema. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A default instance value of this schema. + /// + /// This value is not used to fill in missing values during the validation process. + /// Non-validation tools such as documentation generators or form + /// generators may use this value to give hints to users about how to use + /// a value. + /// However, [default] is typically used to express that if a value is missing, + /// then the value is semantically the same as if the value was present with the + /// default value. + /// The value of [default] should validate against the schema in which it resides, + /// but that isn't required. + /// + /// + default: JsonSchemaValue? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/default. +//documentation +//> A default instance value of this schema. +//> +//> This value is not used to fill in missing values during the validation process. +//> Non-validation tools such as documentation generators or form +//> generators may use this value to give hints to users about how to use +//> a value. +//> However, [`default`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L162,C1) is typically used to express that if a value is missing, +//> then the value is semantically the same as if the value was present with the +//> default value. +//> The value of [`default`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L162,C1) should validate against the schema in which it resides, +//> but that isn't required. +//> +//> +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaValue# + + /// A place to provide a set of examples that validate against the schema. + /// + /// This isn't used for validation, but may help with explaining the effect + /// and purpose of the schema to a reader. + /// Each entry should validate against the schema in which it resides, but + /// that isn't strictly required. + /// There is no need to duplicate the [default] value in the [examples] array, + /// since [default] will be treated as another example. + /// + /// + examples: JsonSchemaValue? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/examples. +//documentation +//> A place to provide a set of examples that validate against the schema. +//> +//> This isn't used for validation, but may help with explaining the effect +//> and purpose of the schema to a reader. +//> Each entry should validate against the schema in which it resides, but +//> that isn't strictly required. +//> There is no need to duplicate the [`default`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L162,C1) value in the [`examples`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L174,C1) array, +//> since [`default`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L162,C1) will be treated as another example. +//> +//> +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaValue# + + /// Indicates that the instance value should not be used and + /// may be removed in the future. + /// + /// Introduced in draft 2019-09. + deprecated: Boolean(availableAfter("https://json-schema.org/draft/2019-09/schema"))? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/deprecated. +//documentation +//> Indicates that the instance value should not be used and +//> may be removed in the future. +//> +//> Introduced in draft 2019-09. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^^^^^^^ reference local availableAfter_56 + + /// Metadata indicating that the instance value should not be modified. + /// + /// It could be used to indicate that a `PUT` request that changes a value would result + /// in a 400 Bad Request response + /// + /// Introduced in draft 7. + readOnly: Boolean(availableAfter("http://json-schema.org/draft-07/schema#"))? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/readOnly. +//documentation +//> Metadata indicating that the instance value should not be modified. +//> +//> It could be used to indicate that a `PUT` request that changes a value would result +//> in a 400 Bad Request response +//> +//> Introduced in draft 7. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^^^^^^^ reference local availableAfter_56 + + /// Metadata indicating that a value may be set, but will remain hidden. + /// + /// In could be used to indicate you can set a value with a `PUT` request, + /// but it would not be included when retrieving that record with a `GET` request + /// + /// Introduced in draft 7. + writeOnly: Boolean(availableAfter("http://json-schema.org/draft-07/schema#"))? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/writeOnly. +//documentation +//> Metadata indicating that a value may be set, but will remain hidden. +//> +//> In could be used to indicate you can set a value with a `PUT` request, +//> but it would not be included when retrieving that record with a `GET` request +//> +//> Introduced in draft 7. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^^^^^^^ reference local availableAfter_56 + + // endregion + // region Core validation + + /// The fundamental data type for a schema. + /// + /// At its core, JSON Schema defines the following basic types: + /// + /// - `string` + /// - `number` + /// - `integer` + /// - `boolean` + /// - `array` + /// - `object` + /// - `null` + /// + /// [type] may either be a string or a listing. + /// + /// - If it's a string, it is the name of one of the basic types above. + /// - If it is an array, it must be an array of strings, where each string + /// is the name of one of the basic types, and each element is unique. + /// In this case, the JSON snippet is valid if it matches *any* of the + /// given types. + /// + /// + type: (JsonSchemaTypeName|Listing)? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/type. +//documentation +//> The fundamental data type for a schema. +//> +//> At its core, JSON Schema defines the following basic types: +//> +//> - `string` +//> - `number` +//> - `integer` +//> - `boolean` +//> - `array` +//> - `object` +//> - `null` +//> +//> [`type`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L222,C1) may either be a string or a listing. +//> +//> - If it's a string, it is the name of one of the basic types above. +//> - If it is an array, it must be an array of strings, where each string +//> is the name of one of the basic types, and each element is unique. +//> In this case, the JSON snippet is valid if it matches *any* of the +//> given types. +//> +//> +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaTypeName# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaTypeName# + + /// Restricts the instance value to a fixed set of values. + /// + /// It must be a listing with at least one element, where each element is unique. + /// You can use [enum] even without a [type], to accept values of different types. + /// + /// Elements in the array might be of any value, including null. + /// + enum: (*JsonSchemaValue|Listing)? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/enum. +//documentation +//> Restricts the instance value to a fixed set of values. +//> +//> It must be a listing with at least one element, where each element is unique. +//> You can use [`enum`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L231,C1) even without a [`type`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L222,C1), to accept values of different types. +//> +//> Elements in the array might be of any value, including null. +//> +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaValue# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaValue# + + /// Restricts the instance value to a single value. + /// + /// + `const`: JsonSchemaValue? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/const. +//documentation +//> Restricts the instance value to a single value. +//> +//> +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/JsonSchemaValue# + + // endregion + // region Number validators + + /// Restricts the instance value to a multiple of the given number. + /// + /// It may be set to any positive number. + /// + /// + multipleOf: Number(isPositive)? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/multipleOf. +//documentation +//> Restricts the instance value to a multiple of the given number. +//> +//> It may be set to any positive number. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#isPositive. + + /// Restricts the instance value to be at minimum the given number. + /// + /// + minimum: Number? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minimum. +//documentation +//> Restricts the instance value to be at minimum the given number. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// Restricts the instance value to be larger than the given number. + /// + /// + exclusiveMinimum: Number? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMinimum. +//documentation +//> Restricts the instance value to be larger than the given number. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// Restricts the instance value to be at maximum the given number. + /// + /// + maximum: Number? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maximum. +//documentation +//> Restricts the instance value to be at maximum the given number. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// Restricts the instance value to be smaller than the given number. + /// + /// + exclusiveMaximum: Number? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/exclusiveMaximum. +//documentation +//> Restricts the instance value to be smaller than the given number. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + // endregion + // region String validators + + /// Restricts the instance value to a regex pattern. + /// + /// The regular expression must conform to [ECMA 262](https://262.ecma-international.org/5.1/#sec-7.8.5). + /// + /// + pattern: String(isRegex)? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/pattern. +//documentation +//> Restricts the instance value to a regex pattern. +//> +//> The regular expression must conform to [ECMA 262](https://262.ecma-international.org/5.1/#sec-7.8.5). +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isRegex. + + /// Restricts the instance value's length to be at minimum the given number. + /// + /// + minLength: UInt? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minLength. +//documentation +//> Restricts the instance value's length to be at minimum the given number. +//> +//> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Restricts the instance value's length to be at maximum the given number. + /// + /// + maxLength: UInt? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxLength. +//documentation +//> Restricts the instance value's length to be at maximum the given number. +//> +//> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Allows for basic semantic validation on certain kinds of string values that are + /// commonly used. + /// + /// This allows values to be constrained beyond what the other tools in JSON Schema, + /// including Regular Expressions can do. + /// + /// + format: ( +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/format. +//documentation +//> Allows for basic semantic validation on certain kinds of string values that are +//> commonly used. +//> +//> This allows values to be constrained beyond what the other tools in JSON Schema, +//> including Regular Expressions can do. +//> +//> + "date-time" + |"time" + |"date" + |"email" + |"idn-email" + |"hostname" + |"ipv4" + |"ipv6" + |"uri" + |"uri-reference" + |"iri" + |"iri-reference" + |"uri-template" + |"json-pointer" + |"relative-json-pointer" + |"regex" + |String)? +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + //endregion + // region Object validators + + /// The properties (key-value pairs) on the instance value. + /// + /// Each key is the name of a property and each value is a schema used to + /// validate that property. + /// Any property on the instance value that doesn't match any of the property + /// names within [properties] is ignored. + /// + /// + properties: Mapping? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/properties. +//documentation +//> The properties (key-value pairs) on the instance value. +//> +//> Each key is the name of a property and each value is a schema used to +//> validate that property. +//> Any property on the instance value that doesn't match any of the property +//> names within [`properties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L325,C1) is ignored. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// Specifies that properties on the instance value that match the specified + /// regular expression should conform to a certain schema. + /// + /// Sometimes you want to say that, given a particular kind of property name, + /// the value should match a particular schema. That’s where + /// [patternProperties] comes in: it maps regular expressions to schemas. + /// If a property name matches the given regular expression, the property + /// value must validate against the corresponding schema. + /// + /// + patternProperties: Mapping? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/patternProperties. +//documentation +//> Specifies that properties on the instance value that match the specified +//> regular expression should conform to a certain schema. +//> +//> Sometimes you want to say that, given a particular kind of property name, +//> the value should match a particular schema. That’s where +//> [`patternProperties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L337,C1) comes in: it maps regular expressions to schemas. +//> If a property name matches the given regular expression, the property +//> value must validate against the corresponding schema. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isRegex. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// Controls the handling of any properties on the instance value that are + /// not listed within [properties], or match any of the regular expressions in + /// [patternProperties]. + /// + /// By default, any additional properties are allowed. + /// + /// Setting the [additionalProperties] to [false] means no additional + /// properties will be allowed. + /// + /// + additionalProperties: Schema? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalProperties. +//documentation +//> Controls the handling of any properties on the instance value that are +//> not listed within [`properties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L325,C1), or match any of the regular expressions in +//> [`patternProperties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L337,C1). +//> +//> By default, any additional properties are allowed. +//> +//> Setting the [`additionalProperties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L349,C1) to `false` means no additional +//> properties will be allowed. +//> +//> +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// Properties that are required to exist on the instance value. + /// + /// By default, no properties are required. + /// + /// The `required` keyword takes an array of zero or more strings. Each + /// of these strings must be unique. + /// + /// + required: Listing? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/required. +//documentation +//> Properties that are required to exist on the instance value. +//> +//> By default, no properties are required. +//> +//> The `required` keyword takes an array of zero or more strings. Each +//> of these strings must be unique. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Validate that the property names match a schema. + /// + /// The [type] for the schema is implicitly `"string"`. + /// + /// + propertyNames: Schema? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/propertyNames. +//documentation +//> Validate that the property names match a schema. +//> +//> The [`type`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L222,C1) for the schema is implicitly `"string"`. +//> +//> +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// The minimum amount of properties that the instance value should have. + /// + /// + minProperties: UInt? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minProperties. +//documentation +//> The minimum amount of properties that the instance value should have. +//> +//> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// The maximum amount of properties that the instance value should have. + /// + /// + maxProperties: UInt? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxProperties. +//documentation +//> The maximum amount of properties that the instance value should have. +//> +//> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + // endregion + // region Array validators + + /// Constraints on items within an array. + /// + /// There are two ways in which arrays are generally used in JSON: + /// + /// - **List validation:** a sequence of arbitrary length where each + /// item matches the same schema. + /// + /// - **Tuple validation:** a sequence of fixed length where each item may + /// have a different schema. In this usage, the index (or location) of + /// each item is meaningful as to how the value is interpreted. (This + /// usage is often given a whole separate type in some programming + /// languages, such as Python's `tuple`). + /// + /// + items: (*Schema|Listing)? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/items. +//documentation +//> Constraints on items within an array. +//> +//> There are two ways in which arrays are generally used in JSON: +//> +//> - **List validation:** a sequence of arbitrary length where each +//> item matches the same schema. +//> +//> - **Tuple validation:** a sequence of fixed length where each item may +//> have a different schema. In this usage, the index (or location) of +//> each item is meaningful as to how the value is interpreted. (This +//> usage is often given a whole separate type in some programming +//> languages, such as Python's `tuple`). +//> +//> +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// Controls whether it’s valid to have additional items in a tuple beyond what is + /// defined in items. + /// + /// The value of the [additionalItems] is a schema that all additional items must pass + /// in order for the keyword to validate. + /// This is ignored if there is not a “tuple validation” items + /// keyword present in the same schema. + /// + /// + additionalItems: Schema? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/additionalItems. +//documentation +//> Controls whether it’s valid to have additional items in a tuple beyond what is +//> defined in items. +//> +//> The value of the [`additionalItems`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L406,C1) is a schema that all additional items must pass +//> in order for the keyword to validate. +//> This is ignored if there is not a “tuple validation” items +//> keyword present in the same schema. +//> +//> +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// A schema that must match at least one item within the instance array. + /// + /// + contains: Schema? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/contains. +//documentation +//> A schema that must match at least one item within the instance array. +//> +//> +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// Constrains the instance value's length to be at minimum the given number. + /// + /// + minItems: UInt? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/minItems. +//documentation +//> Constrains the instance value's length to be at minimum the given number. +//> +//> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Constrains the instance value's length to be at maximum the given number. + /// + /// + maxItems: UInt? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/maxItems. +//documentation +//> Constrains the instance value's length to be at maximum the given number. +//> +//> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Specifies that each item in the instance value is unique. + /// + /// + uniqueItems: Boolean? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/uniqueItems. +//documentation +//> Specifies that each item in the instance value is unique. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + // endregion + // region Composition + + /// Specifies that the value must match against **exactly** one of the subschemas. + /// + /// + oneOf: Listing(!isEmpty)? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/oneOf. +//documentation +//> Specifies that the value must match against **exactly** one of the subschemas. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + + /// Specifies that the value must match ay least one of the subschemas. + /// + /// + anyOf: Listing(!isEmpty)? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/anyOf. +//documentation +//> Specifies that the value must match ay least one of the subschemas. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + + /// Specifies that the value must match **all** of the subschemas. + /// + /// + allOf: Listing(!isEmpty)? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/allOf. +//documentation +//> Specifies that the value must match **all** of the subschemas. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + + /// The `not` keyword declares that an instance validates if it doesn’t validate + /// against the given subschema. + /// + /// + not: Schema? +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/not. +//documentation +//> The `not` keyword declares that an instance validates if it doesn’t validate +//> against the given subschema. +//> +//> +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// The dependentRequired keyword conditionally requires that certain properties + /// must be present if a given property is present in an object + /// + /// + dependentRequired: Mapping>? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/dependentRequired. +//documentation +//> The dependentRequired keyword conditionally requires that certain properties +//> must be present if a given property is present in an object +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The dependentSchemas keyword conditionally applies a subschema when a given property is present. + /// This schema is applied in the same way allOf applies schemas + /// + /// + dependentSchemas: Mapping? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/dependentSchemas. +//documentation +//> The dependentSchemas keyword conditionally applies a subschema when a given property is present. +//> This schema is applied in the same way allOf applies schemas +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// The `if`, `then` and `else` keywords allow the application of a subschema based on the outcome of another schema + /// If `if` is valid, `then` must also be valid (and `else` is ignored.) If `if` is invalid, `else` must also be valid (and `then` is ignored) + /// If `then` or `else` is not defined, `if` behaves as if they have a value of `true`. + /// + /// + `if`: Schema? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/if. +//documentation +//> The `if`, `then` and `else` keywords allow the application of a subschema based on the outcome of another schema +//> If `if` is valid, `then` must also be valid (and `else` is ignored.) If `if` is invalid, `else` must also be valid (and `then` is ignored) +//> If `then` or `else` is not defined, `if` behaves as if they have a value of `true`. +//> +//> +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// If `then` and/or `else` appear in a schema without `if`, `then` and `else` are ignored. + then: Schema? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/then. +//documentation +//> If `then` and/or `else` appear in a schema without `if`, `then` and `else` are ignored. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + /// If `then` and/or `else` appear in a schema without `if`, `then` and `else` are ignored. + `else`: Schema? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/else. +//documentation +//> If `then` and/or `else` appear in a schema without `if`, `then` and `else` are ignored. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + // endregion + + /// Any additional properties that are [JsonSchema]. + /// + /// Additional properties do not affect the validation of the instance value, but + /// may be referred to using [$ref]. + /// + /// This is a child property because Pkl modules cannot express both known names + /// and arbitrary names. + _inline_: Mapping? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/_inline_. +//documentation +//> Any additional properties that are [`JsonSchema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L22,C1). +//> +//> Additional properties do not affect the validation of the instance value, but +//> may be referred to using [`$ref`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L98,C1). +//> +//> This is a child property because Pkl modules cannot express both known names +//> and arbitrary names. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/output. + renderer = new JsonRenderer { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/renderer. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/converters. + [module.getClass()] = (s: JsonSchema) -> s.toMap().remove("_inline_") + (s._inline_?.toMap() ?? Map()) +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^ definition local s_491 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^ reference local s_491 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#remove(). +// ^ reference local s_491 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/_inline_. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + } + } + } + diff --git a/pkl-pantrysnapshot/org.json_schema/Parser.pkl b/pkl-pantrysnapshot/org.json_schema/Parser.pkl new file mode 100755 index 00000000..af4eb83b --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema/Parser.pkl @@ -0,0 +1,484 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Utility methods for parsing values into [JsonSchema]. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/minPklVersion. + module org.json_schema.Parser +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/ + + import "pkl:json" + import "pkl:reflect" + + import "JsonSchema.pkl" + + local jsonParser = new json.Parser { useMapping = true } +// ^^^^^^^^^^ definition local jsonParser_25 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.json`/Parser# +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/useMapping. + + local knownSchemaKeys: Set = reflect.Module(JsonSchema).moduleClass.properties.keys +// ^^^^^^^^^^^^^^^ definition local knownSchemaKeys_27 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#moduleClass. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#properties. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#keys. + + local function toJsonSchema( +// ^^^^^^^^^^^^ definition local toJsonSchema_29 + raw: Mapping|Boolean, +// ^^^ definition local raw_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + baseSchema: JsonSchema?, +// ^^^^^^^^^^ definition local baseSchema_31 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/ + path: List +// ^^^^ definition local path_32 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + ): JsonSchema.Schema = +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + if (raw is Boolean) +// ^^^ reference local raw_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + raw +// ^^^ reference local raw_30 + else + new { + $$baseSchema = baseSchema ?? this +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^^^^^^^ reference local baseSchema_31 + $id = raw.getOrNull("$id") +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$id. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + $ref = raw.getOrNull("$ref") +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$ref. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + $schema = raw.getOrNull("$schema") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$schema. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + $comment = raw.getOrNull("$comment") +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$comment. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + $defs = (raw.getOrNull("$defs") as Mapping?) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$defs. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ?.toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + ?.map((key, value) -> Pair(key, toJsonSchema(value, $$baseSchema, path.add("definitions").add(key)))) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#map(). +// ^^^ definition local key_45 +// ^^^^^ definition local value_45 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^ reference local key_45 +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^^ reference local value_45 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local key_45 + ?.toMapping() +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMapping(). + definitions = (raw.getOrNull("definitions") as Mapping?) +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/definitions. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ?.toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + ?.map((key, value) -> Pair(key, toJsonSchema(value, $$baseSchema, path.add("$defs").add(key)))) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#map(). +// ^^^ definition local key_49 +// ^^^^^ definition local value_49 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^ reference local key_49 +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^^ reference local value_49 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local key_49 + ?.toMapping() +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMapping(). + type = raw.getOrNull("type") +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/type. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + format = raw.getOrNull("format") +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/format. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + pattern = raw.getOrNull("pattern") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/pattern. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + maxLength = raw.getOrNull("maxLength") +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/maxLength. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + minLength = raw.getOrNull("minLength") +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/minLength. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + title = raw.getOrNull("title") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/title. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + description = raw.getOrNull("description") +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/description. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + multipleOf = raw.getOrNull("multipleOf") +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/multipleOf. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + minimum = raw.getOrNull("minimum") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/minimum. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + maximum = raw.getOrNull("maximum") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/maximum. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + exclusiveMinimum = raw.getOrNull("exclusiveMinimum") +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/exclusiveMinimum. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + exclusiveMaximum = raw.getOrNull("exclusiveMaximum") +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/exclusiveMaximum. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + examples = raw.getOrNull("examples") +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/examples. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + allOf = (raw.getOrNull("allOf") as Listing?) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/allOf. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + ?.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + ?.mapIndexed((idx, elem) -> toJsonSchema(elem, $$baseSchema, path.add("allOf").add(idx))) +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#mapIndexed(). +// ^^^ definition local idx_66 +// ^^^^ definition local elem_66 +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^ reference local elem_66 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local idx_66 + ?.toListing() +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toListing(). + anyOf = (raw.getOrNull("anyOf") as Listing?) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/anyOf. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + ?.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + ?.mapIndexed((idx, elem) -> toJsonSchema(elem, $$baseSchema, path.add("anyOf").add(idx))) +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#mapIndexed(). +// ^^^ definition local idx_70 +// ^^^^ definition local elem_70 +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^ reference local elem_70 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local idx_70 + ?.toListing() +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toListing(). + oneOf = (raw.getOrNull("oneOf") as Listing?) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/oneOf. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + ?.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + ?.mapIndexed((idx, elem) -> toJsonSchema(elem, $$baseSchema, path.add("oneOf").add(idx))) +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#mapIndexed(). +// ^^^ definition local idx_74 +// ^^^^ definition local elem_74 +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^ reference local elem_74 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local idx_74 + ?.toListing() +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toListing(). + not = if (raw.containsKey("not")) toJsonSchema(raw["not"], $$baseSchema, path.add("not")) else null +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/not. +// ^^^ reference local raw_30 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^ reference local raw_30 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). + properties = (raw.getOrNull("properties") as Mapping?) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/properties. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ?.toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + ?.map((key, value) -> Pair(key, toJsonSchema(value, $$baseSchema, path.add("properties").add(key)))) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#map(). +// ^^^ definition local key_79 +// ^^^^^ definition local value_79 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^ reference local key_79 +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^^ reference local value_79 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local key_79 + ?.toMapping() +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMapping(). + items = +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/items. + let (rawItems = raw.getOrNull("items")) +// ^^^^^^^^ definition local rawItems_82 +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + if (rawItems == null) null +// ^^^^^^^^ reference local rawItems_82 + else if (rawItems is Listing) +// ^^^^^^^^ reference local rawItems_82 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + rawItems +// ^^^^^^^^ reference local rawItems_82 + .toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + .mapIndexed((idx, elem) -> toJsonSchema(elem, $$baseSchema, path.add("items").add(idx))) +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#mapIndexed(). +// ^^^ definition local idx_87 +// ^^^^ definition local elem_87 +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^ reference local elem_87 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local idx_87 + .toListing() +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toListing(). + else toJsonSchema(rawItems, $$baseSchema, path.add("items")) +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^^^^^ reference local rawItems_82 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). + additionalItems = +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/additionalItems. + let (rawAdditionalItems = raw.getOrNull("additionalItems")) +// ^^^^^^^^^^^^^^^^^^ definition local rawAdditionalItems_91 +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + if (rawAdditionalItems == null) null +// ^^^^^^^^^^^^^^^^^^ reference local rawAdditionalItems_91 + else toJsonSchema(rawAdditionalItems, $$baseSchema, path.add("additionalItems")) +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^^^^^^^^^^^^^^^ reference local rawAdditionalItems_91 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). + contains = +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/contains. + let (rawContains = raw.getOrNull("contains")) +// ^^^^^^^^^^^ definition local rawContains_95 +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + if (rawContains == null) null +// ^^^^^^^^^^^ reference local rawContains_95 + else toJsonSchema(rawContains, $$baseSchema, path.add("contains")) +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^^^^^^^^ reference local rawContains_95 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). + minItems = raw.getOrNull("minItems") +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/minItems. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + maxItems = raw.getOrNull("maxItems") +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/maxItems. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + uniqueItems = raw.getOrNull("uniqueItems") +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/uniqueItems. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + default = raw.getOrNull("default") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/default. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + deprecated = raw.getOrNull("deprecated") +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/deprecated. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + readOnly = raw.getOrNull("readOnly") +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/readOnly. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + writeOnly = raw.getOrNull("writeOnly") +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/writeOnly. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + enum = raw.getOrNull("enum") +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/enum. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + required = raw.getOrNull("required") +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/required. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + `const` = raw.getOrNull("const") +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/const. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + propertyNames = let (_raw = raw.getOrNull("propertyNames")) +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/propertyNames. +// ^^^^ definition local _raw_108 +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + if (_raw == null) null +// ^^^^ reference local _raw_108 + else toJsonSchema(_raw, $$baseSchema, path.add("propertyNames")) +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^ reference local _raw_108 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). + maxProperties = raw.getOrNull("maxProperties") +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/maxProperties. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + minProperties = raw.getOrNull("minProperties") +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/minProperties. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + additionalProperties = +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/additionalProperties. + let (rawAdditionalProperties = raw.getOrNull("additionalProperties")) +// ^^^^^^^^^^^^^^^^^^^^^^^ definition local rawAdditionalProperties_114 +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). + if (rawAdditionalProperties == null) null +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local rawAdditionalProperties_114 + else toJsonSchema(rawAdditionalProperties, $$baseSchema, path.add("additionalProperties")) +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local rawAdditionalProperties_114 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). + patternProperties = (raw.getOrNull("patternProperties") as Mapping?) +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/patternProperties. +// ^^^ reference local raw_30 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ?.toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + ?.map((key, value) -> Pair(key, toJsonSchema(value, $$baseSchema, path.add("patternProperties").add(key)))) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#map(). +// ^^^ definition local key_119 +// ^^^^^ definition local value_119 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^ reference local key_119 +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^^ reference local value_119 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local key_119 + ?.toMapping() +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMapping(). + _inline_ = raw.toMap() +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/_inline_. +// ^^^ reference local raw_30 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + .filter((key, value) -> !knownSchemaKeys.contains(key) && value is Boolean|Mapping) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^ definition local key_122 +// ^^^^^ definition local value_122 +// ^^^^^^^^^^^^^^^ reference local knownSchemaKeys_27 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). +// ^^^ reference local key_122 +// ^^^^^ reference local value_122 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + .map((key, value) -> Pair(key, toJsonSchema(value, $$baseSchema, path.add(key)))) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#map(). +// ^^^ definition local key_123 +// ^^^^^ definition local value_123 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^ reference local key_123 +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^^ reference local value_123 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/$$baseSchema. +// ^^^^ reference local path_32 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local key_123 + .toMapping() +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMapping(). + } + + /// Given a JSON string or [Resource], parse it into a [JsonSchema.Schema] instance. + function parse(src: Resource|String): JsonSchema.Schema = +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `Parser.pkl`/parse(). +// documentation +// > Given a JSON string or [`Resource`](pkl-lsp://stdlib/base.pkl#L519,C7), parse it into a [`JsonSchema.Schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.json_schema/JsonSchema.pkl#L46,C11) instance. +// ^^^ definition local src_128 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `JsonSchema.pkl`/Schema# + let (jsonParsed: Mapping|Boolean = jsonParser.parse(src) as Mapping|Boolean) +// ^^^^^^^^^^ definition local jsonParsed_129 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^^^ reference local jsonParser_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.json`/Parser#parse(). +// ^^^ reference local src_128 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + toJsonSchema(jsonParsed, null, List()) +// ^^^^^^^^^^^^ reference local toJsonSchema_29 +// ^^^^^^^^^^ reference local jsonParsed_129 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + diff --git a/pkl-pantrysnapshot/org.json_schema/PklProject b/pkl-pantrysnapshot/org.json_schema/PklProject new file mode 100755 index 00000000..63a4a0d1 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema/PklProject @@ -0,0 +1,32 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Modules for [JSON Schema](https://json-schema.org). + /// + /// This package includes utilities for resolving JSON Schema references, as well as generating Pkl modules from a + /// JSON Schema document. + amends "../basePklProject.pkl" + + dependencies { +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 PklProject/dependencies. + ["uri"] = import("../pkl.experimental.uri/PklProject") + } + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 PklProject/package. + version = "1.1.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/org.json_schema/examples/basic.pkl b/pkl-pantrysnapshot/org.json_schema/examples/basic.pkl new file mode 100755 index 00000000..6ac48c3a --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema/examples/basic.pkl @@ -0,0 +1,53 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + amends "../JsonSchema.pkl" + + $id = "https://example.com/person.schema.json" +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/$id. + + $schema = "https://json-schema.org/draft/2020-12/schema" +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/$schema. + + title = "Person" +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/title. + + type = "object" +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/type. + + properties { +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/properties. + ["firstName"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/type. + description = "The person's first name" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/description. + } + ["lastName"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/type. + description = "The person's last name" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/description. + } + ["age"] { + type = "integer" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/type. + description = "Age in years which must be equal to or greater than zero." +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/description. + minimum = 0 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `examples/basic.pkl`/minimum. + } + } + diff --git a/pkl-pantrysnapshot/org.json_schema/tests/JsonSchema.pkl b/pkl-pantrysnapshot/org.json_schema/tests/JsonSchema.pkl new file mode 100755 index 00000000..81b2dfe9 --- /dev/null +++ b/pkl-pantrysnapshot/org.json_schema/tests/JsonSchema.pkl @@ -0,0 +1,41 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.json_schema.tests.JsonSchema +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `tests/JsonSchema.pkl`/ + + amends "pkl:test" + + local allExamples = import*("../examples/*.pkl") +// ^^^^^^^^^^^ definition local allExamples_20 + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.json_schema 1.1.0 `tests/JsonSchema.pkl`/examples. + for (example in allExamples.keys) { +// ^^^^^^^ definition local example_23 +// ^^^^^^^^^^^ reference local allExamples_20 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#keys. + [example.drop(12).replaceLast("pkl", "json")] { +// ^^^^^^^ reference local example_23 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceLast(). + allExamples[example].output.text +// ^^^^^^^^^^^ reference local allExamples_20 +// ^^^^^^^ reference local example_23 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + } diff --git a/pkl-pantrysnapshot/org.openapis.v3.contrib/PklProject b/pkl-pantrysnapshot/org.openapis.v3.contrib/PklProject new file mode 100755 index 00000000..fd8fc700 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3.contrib/PklProject @@ -0,0 +1,28 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 PklProject/package. + version = "1.1.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 PklProject/version. + } + + dependencies { +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 PklProject/dependencies. + ["openapi"] = import("../org.openapis.v3/PklProject") + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3.contrib/SchemaGenerator.pkl b/pkl-pantrysnapshot/org.openapis.v3.contrib/SchemaGenerator.pkl new file mode 100755 index 00000000..af0b6d76 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3.contrib/SchemaGenerator.pkl @@ -0,0 +1,871 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Enables the generation of a [Schema] from a Pkl module, class, or typealias. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/minPklVersion. + module org.openapis.v3.contrib.SchemaGenerator +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/ + + import "pkl:reflect" + import "pkl:math" + import "@openapi/Schema.pkl" + + /// Given either a module, class, or typealias, generates the equivalent OpenAPI v3.0 [Schema]. + /// + /// Example: + /// ``` + /// import "package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib@1.0.0#/SchemaGenerator.pkl" + /// + /// class Person { + /// /// The person's legal name. + /// name: String? + /// } + /// + /// personSchema = SchemaGenerator.generate(Person) + /// ``` + /// + /// `personSchema` generates a schema that looks like so: + /// + /// ```json + /// { + /// "type": "object", + /// "title": "Person", + /// "properties": { + /// "name": { + /// "type": "string", + /// "description": "The person's legal name.", + /// "nullable": true + /// } + /// }, + /// "additionalProperties": false, + /// "required": [] + /// } + /// ``` + /// + /// Known limitations: + /// * This generator cannot generate schemas that contain recursive descriptors, + /// because a single [Schema] lacks the ability to reuse definitions. + /// * [Type Constraints](https://pkl-lang.org/main/current/language-reference/index.html#type-constraints) + /// do not get encoded into the [Schema]. The only exceptions are well-known type constraints for + /// numbers (for example, [Int8] and [UInt8]). + function generate(value: Module|Class|TypeAlias): Schema = +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/generate(). +// documentation +// > Given either a module, class, or typealias, generates the equivalent OpenAPI v3.0 [`Schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L32,C1). +// > +// > Example: +// > ``` +// > import "package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib@1.0.0#/SchemaGenerator.pkl" +// > +// > class Person { +// > /// The person's legal name. +// > name: String? +// > } +// > +// > personSchema = SchemaGenerator.generate(Person) +// > ``` +// > +// > `personSchema` generates a schema that looks like so: +// > +// > ```json +// > { +// > "type": "object", +// > "title": "Person", +// > "properties": { +// > "name": { +// > "type": "string", +// > "description": "The person's legal name.", +// > "nullable": true +// > } +// > }, +// > "additionalProperties": false, +// > "required": [] +// > } +// > ``` +// > +// > Known limitations: +// > * This generator cannot generate schemas that contain recursive descriptors, +// > because a single [`Schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L32,C1) lacks the ability to reuse definitions. +// > * [Type Constraints](https://pkl-lang.org/main/current/language-reference/index.html#type-constraints) +// > do not get encoded into the [`Schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L32,C1). The only exceptions are well-known type constraints for +// > numbers (for example, [`Int8`](pkl-lsp://stdlib/base.pkl#L941,C11) and [`UInt8`](pkl-lsp://stdlib/base.pkl#L950,C11)). +// ^^^^^ definition local value_62 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + let (ref = if (value is Module) +// ^^^ definition local ref_63 +// ^^^^^ reference local value_62 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module# + reflect.Module(value) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module(). +// ^^^^^ reference local value_62 + else if (value is TypeAlias) +// ^^^^^ reference local value_62 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# + reflect.TypeAlias(value) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias(). +// ^^^^^ reference local value_62 + else + reflect.Class(value) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^^^^^ reference local value_62 + ) + convertDeclaration(ref, Set()) +// ^^^^^^^^^^^^^^^^^^ reference local convertDeclaration_93 +// ^^^ reference local ref_63 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). + + /// Customize how the generator produces JSON Schema. This is useful if a Pkl type is expected + /// to map to a (non-standard) JSON Schema type. + /// + /// To use converters, a new instance of [SchemaGenerator] must be initialized. + /// + /// Example: + /// ``` + /// import "package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3@1.0.0#/SchemaGenerator.pkl" + /// + /// k8sGenerator = new SchemaGenerator { + /// converters { + /// [DataSize] { + /// type = "string" + /// description = "A Kubernetes data size representation. For instance, 5Mi" + /// pattern = "^\d+(?:[EPTGMK]i?)?$" + /// } + /// } + /// } + /// ``` + hidden converters: Mapping +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/converters. +// documentation +// > Customize how the generator produces JSON Schema. This is useful if a Pkl type is expected +// > to map to a (non-standard) JSON Schema type. +// > +// > To use converters, a new instance of `SchemaGenerator` must be initialized. +// > +// > Example: +// > ``` +// > import "package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3@1.0.0#/SchemaGenerator.pkl" +// > +// > k8sGenerator = new SchemaGenerator { +// > converters { +// > [`DataSize`](pkl-lsp://stdlib/base.pkl#L1634,C16) { +// > type = "string" +// > description = "A Kubernetes data size representation. For instance, 5Mi" +// > pattern = "^\d+(?:`EPTGMK`i?)?$" +// > } +// > } +// > } +// > ``` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + + /// Converts a [reflect.Declaration] into the equivalent [Schema]. + local function convertDeclaration(declaration: reflect.Declaration, seenClasses: Set): Schema = +// ^^^^^^^^^^^^^^^^^^ definition local convertDeclaration_93 +// documentation +// > Converts a [`reflect.Declaration`](pkl-lsp://stdlib/reflect.pkl#L164,C25) into the equivalent [`Schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L32,C1). +// ^^^^^^^^^^^ definition local declaration_94 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration# +// ^^^^^^^^^^^ definition local seenClasses_94 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + if (declaration is reflect.Class) +// ^^^^^^^^^^^ reference local declaration_94 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# + convertType(reflect.DeclaredType(declaration), seenClasses) +// ^^^^^^^^^^^ reference local convertType_248 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType(). +// ^^^^^^^^^^^ reference local declaration_94 +// ^^^^^^^^^^^ reference local seenClasses_94 + else if (declaration is reflect.Module) +// ^^^^^^^^^^^ reference local declaration_94 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module# + (convertDeclaration(declaration.moduleClass, seenClasses)) { +// ^^^^^^^^^^^^^^^^^^ reference local convertDeclaration_93 +// ^^^^^^^^^^^ reference local declaration_94 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#moduleClass. +// ^^^^^^^^^^^ reference local seenClasses_94 + // We need to amend title because it would otherwise be `"ModuleClass"`. + title = declaration.name +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/title. +// ^^^^^^^^^^^ reference local declaration_94 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#name. + } + else if (declaration is reflect.Property) +// ^^^^^^^^^^^ reference local declaration_94 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# + convertType(declaration.type, seenClasses) |> addBaseSchema(declaration) +// ^^^^^^^^^^^ reference local convertType_248 +// ^^^^^^^^^^^ reference local declaration_94 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^^ reference local seenClasses_94 +// ^^^^^^^^^^^^^ reference local addBaseSchema_107 +// ^^^^^^^^^^^ reference local declaration_94 + else + convertType((declaration as reflect.TypeAlias).referent, seenClasses) |> addBaseSchema(declaration) +// ^^^^^^^^^^^ reference local convertType_248 +// ^^^^^^^^^^^ reference local declaration_94 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias#referent. +// ^^^^^^^^^^^ reference local seenClasses_94 +// ^^^^^^^^^^^^^ reference local addBaseSchema_107 +// ^^^^^^^^^^^ reference local declaration_94 + + /// Adds common base values to a [Schema]. + local function addBaseSchema(declaration: reflect.Declaration): Mixin = new { +// ^^^^^^^^^^^^^ definition local addBaseSchema_107 +// documentation +// > Adds common base values to a [`Schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L32,C1). +// ^^^^^^^^^^^ definition local declaration_108 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mixin# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + description = declaration.docComment +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/description. +// ^^^^^^^^^^^ reference local declaration_108 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#docComment. + // If this is a `Property`, the name is the name of the property, which is not a good + // indication of the underlying type. Therefore, we only apply the title when the + // declaration is not a property. + when (!(declaration is reflect.Property)) { +// ^^^^^^^^^^^ reference local declaration_108 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# + title = declaration.name +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/title. +// ^^^^^^^^^^^ reference local declaration_108 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#name. + } + when (!declaration.annotations.filter((a) -> a is Deprecated).isEmpty) { +// ^^^^^^^^^^^ reference local declaration_108 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#annotations. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filter(). +// ^ definition local a_116 +// ^ reference local a_116 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Deprecated# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + deprecated = true +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/deprecated. + } + } + + local function convertDeclaredType(typ: reflect.DeclaredType, seenClasses: Set): Schema = +// ^^^^^^^^^^^^^^^^^^^ definition local convertDeclaredType_121 +// ^^^ definition local typ_121 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# +// ^^^^^^^^^^^ definition local seenClasses_121 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + let (reflectee = typ.referent.reflectee) +// ^^^^^^^^^ definition local reflectee_122 +// ^^^ reference local typ_121 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. + if (reflectee == Any || typ == reflect.unknownType) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference local typ_121 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/unknownType. + new {} + else if (reflectee == Int) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + new { + type = "integer" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + } + else if (reflectee == Int8) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int8# + new { + type = "integer" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + minimum = math.minInt8 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/minimum. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/minInt8. + maximum = math.maxInt8 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/maximum. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxInt8. + } + else if (reflectee == Int16) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int16# + new { + type = "integer" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + minimum = math.minInt16 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/minimum. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/minInt16. + maximum = math.maxInt16 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/maximum. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxInt16. + } + else if (reflectee == Int32) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int32# + new { + type = "integer" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + format = "int32" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/format. + } + else if (reflectee == UInt8) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# + new { + type = "integer" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + minimum = 0 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/minimum. + maximum = math.maxUInt8 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/maximum. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt8. + } + else if (reflectee == UInt16) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt16# + new { + type = "integer" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + minimum = 0 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/minimum. + maximum = math.maxUInt16 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/maximum. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt16. + } + else if (reflectee == UInt32) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# + new { + type = "integer" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + minimum = 0 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/minimum. + maximum = math.maxUInt32 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/maximum. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + } + else if (reflectee == Float) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + new { + type = "number" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + format = "float" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/format. + } + else if (reflectee == Dynamic) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + new { + oneOf { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/oneOf. + new { + type = "array" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + } + new { + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + } + } + } + else if (reflectee == Boolean) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + new { + type = "boolean" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + } + else if (reflectee == Null) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# + new { + enum { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/enum. + null + } + } + else if (reflectee == Number) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + new { + type = "number" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + } + else if (reflectee == String) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + new { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + } + else if (typ == reflect.nothingType) +// ^^^ reference local typ_121 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/nothingType. + // This type is `NOT ANY`, ergo, nothing. + new { + not {} +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/not. + } + else if (reflectee == Listing || reflectee == List) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# + let (elementType = typ.typeArguments[0]) +// ^^^^^^^^^^^ definition local elementType_204 +// ^^^ reference local typ_121 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#typeArguments. + new { + type = "array" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + items = convertType(elementType, seenClasses) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/items. +// ^^^^^^^^^^^ reference local convertType_248 +// ^^^^^^^^^^^ reference local elementType_204 +// ^^^^^^^^^^^ reference local seenClasses_121 + } + else if (reflectee == Mapping || reflectee == Map) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^ reference local reflectee_122 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# + let (keyType = typ.typeArguments[0]) +// ^^^^^^^ definition local keyType_210 +// ^^^ reference local typ_121 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#typeArguments. + let (valueType = typ.typeArguments[1]) +// ^^^^^^^^^ definition local valueType_211 +// ^^^ reference local typ_121 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#typeArguments. + if (keyType != reflect.stringType) +// ^^^^^^^ reference local keyType_210 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/stringType. + throw("Invalid schema: Mappings can only be a string type when converting to JSON schema. Received: \(keyType)") +// ^^^^^^^ reference local keyType_210 + else + new { + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + additionalProperties = convertTypeForProperty(valueType, seenClasses) +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/additionalProperties. +// ^^^^^^^^^^^^^^^^^^^^^^ reference local convertTypeForProperty_281 +// ^^^^^^^^^ reference local valueType_211 +// ^^^^^^^^^^^ reference local seenClasses_121 + } + else if (reflectee is Class) +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# + if (seenClasses.findOrNull((c) -> c == typ.referent.reflectee) != null) +// ^^^^^^^^^^^ reference local seenClasses_121 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#findOrNull(). +// ^ definition local c_220 +// ^ reference local c_220 +// ^^^ reference local typ_121 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. + throw("Invalid Schema: Unable to convert a schema that refers to itself. This is because OpenAPI v3.0 does not have a way to provide definitions. Recurring class: \(typ.referent.reflectee)") +// ^^^ reference local typ_121 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. + else + converters.getOrNull(typ.referent.reflectee) ?? +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/converters. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^ reference local typ_121 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. + let (reflectedClass = reflect.Class(reflectee)) +// ^^^^^^^^^^^^^^ definition local reflectedClass_224 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^^^^^^^^^ reference local reflectee_122 + let (_properties = getProperties(reflectedClass)) +// ^^^^^^^^^^^ definition local _properties_225 +// ^^^^^^^^^^^^^ reference local getProperties_308 +// ^^^^^^^^^^^^^^ reference local reflectedClass_224 + new Schema { +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/properties. + for (_, property in _properties) { +// ^^^^^^^^ definition local property_229 +// ^^^^^^^^^^^ reference local _properties_225 + [property.name] = +// ^^^^^^^^ reference local property_229 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#name. + convertDeclarationForProperty(property, seenClasses.add(reflectee)) +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local convertDeclarationForProperty_285 +// ^^^^^^^^ reference local property_229 +// ^^^^^^^^^^^ reference local seenClasses_121 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#add(). +// ^^^^^^^^^ reference local reflectee_122 + } + } + additionalProperties = false +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/additionalProperties. + when (_properties.any((_, property) -> property.type.nullable != property.type)) { +// ^^^^^^^^^^^ reference local _properties_225 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#any(). +// ^^^^^^^^ definition local property_235 +// ^^^^^^^^ reference local property_235 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type#nullable. +// ^^^^^^^^ reference local property_235 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. + required { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/required. + for (_, property in _properties) { +// ^^^^^^^^ definition local property_237 +// ^^^^^^^^^^^ reference local _properties_225 + when (property.type.nullable != property.type) { +// ^^^^^^^^ reference local property_237 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type#nullable. +// ^^^^^^^^ reference local property_237 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. + property.name +// ^^^^^^^^ reference local property_237 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#name. + } + } + } + } + } |> addBaseSchema(reflectedClass) +// ^^^^^^^^^^^^^ reference local addBaseSchema_107 +// ^^^^^^^^^^^^^^ reference local reflectedClass_224 + else + convertDeclaration(reflect.TypeAlias(reflectee), seenClasses) +// ^^^^^^^^^^^^^^^^^^ reference local convertDeclaration_93 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias(). +// ^^^^^^^^^ reference local reflectee_122 +// ^^^^^^^^^^^ reference local seenClasses_121 + + /// Given a `reflect.Type`, produce a matching [Schema]. + local function convertType(typ: reflect.Type, seenClasses: Set): Schema = +// ^^^^^^^^^^^ definition local convertType_248 +// documentation +// > Given a `reflect.Type`, produce a matching [`Schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L32,C1). +// ^^^ definition local typ_249 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^^^^^^^ definition local seenClasses_249 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + if (typ is reflect.NullableType) +// ^^^ reference local typ_249 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType# + (convertType(typ.member, seenClasses)) { +// ^^^^^^^^^^^ reference local convertType_248 +// ^^^ reference local typ_249 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType#member. +// ^^^^^^^^^^^ reference local seenClasses_249 + nullable = true +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/nullable. + } + else if (typ is reflect.UnionType && typ.members.every((it) -> it is reflect.StringLiteralType)) +// ^^^ reference local typ_249 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType# +// ^^^ reference local typ_249 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType#members. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^ definition local it_254 +// ^^ reference local it_254 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType# + new { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/type. + enum { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/enum. + for (member in typ.members) { +// ^^^^^^ definition local member_258 +// ^^^ reference local typ_249 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType#members. + (member as reflect.StringLiteralType).value +// ^^^^^^ reference local member_258 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType#value. + } + } + } + else if (typ is reflect.UnionType) +// ^^^ reference local typ_249 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType# + new { + oneOf { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/oneOf. + for (member in typ.members) { +// ^^^^^^ definition local member_266 +// ^^^ reference local typ_249 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType#members. + convertType(member, seenClasses) +// ^^^^^^^^^^^ reference local convertType_248 +// ^^^^^^ reference local member_266 +// ^^^^^^^^^^^ reference local seenClasses_249 + } + } + } + else if (typ is reflect.StringLiteralType) +// ^^^ reference local typ_249 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType# + new { + enum { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/enum. + typ.value +// ^^^ reference local typ_249 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType#value. + } + } + else if (typ is reflect.DeclaredType) +// ^^^ reference local typ_249 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# + convertDeclaredType(typ, seenClasses) +// ^^^^^^^^^^^^^^^^^^^ reference local convertDeclaredType_121 +// ^^^ reference local typ_249 +// ^^^^^^^^^^^ reference local seenClasses_249 + else throw("Unsure how to cast this type: \(typ)") +// ^^^ reference local typ_249 + + /// Same as [convertType], except casts results to [Schema.PropertySchema] + local function convertTypeForProperty(typ: reflect.Type, seenClasses: Set): Schema.PropertySchema = +// ^^^^^^^^^^^^^^^^^^^^^^ definition local convertTypeForProperty_281 +// documentation +// > Same as `convertType`, except casts results to [`Schema.PropertySchema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L373,C7) +// ^^^ definition local typ_282 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^^^^^^^ definition local seenClasses_282 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/PropertySchema# + convertType(typ, seenClasses).toDynamic().toTyped(Schema.PropertySchema) +// ^^^^^^^^^^^ reference local convertType_248 +// ^^^ reference local typ_282 +// ^^^^^^^^^^^ reference local seenClasses_282 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toDynamic(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toTyped(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/PropertySchema# + + /// Same as [convertDeclaration], except casts results to [Schema.PropertySchema]. + local function convertDeclarationForProperty(declaration: reflect.Declaration, seenClasses: Set): Schema.PropertySchema = +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition local convertDeclarationForProperty_285 +// documentation +// > Same as `convertDeclaration`, except casts results to [`Schema.PropertySchema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L373,C7). +// ^^^^^^^^^^^ definition local declaration_286 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration# +// ^^^^^^^^^^^ definition local seenClasses_286 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/PropertySchema# + convertDeclaration(declaration, seenClasses).toDynamic().toTyped(Schema.PropertySchema) +// ^^^^^^^^^^^^^^^^^^ reference local convertDeclaration_93 +// ^^^^^^^^^^^ reference local declaration_286 +// ^^^^^^^^^^^ reference local seenClasses_286 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toDynamic(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toTyped(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/PropertySchema# + + local function isSameType(typeA: reflect.Type, typeB: reflect.Type) = +// ^^^^^^^^^^ definition local isSameType_289 +// ^^^^^ definition local typeA_289 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^ definition local typeB_289 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# + if (typeA is reflect.DeclaredType && typeB is reflect.DeclaredType) +// ^^^^^ reference local typeA_289 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# +// ^^^^^ reference local typeB_289 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# + typeA.referent.reflectee == typeB.referent.reflectee +// ^^^^^ reference local typeA_289 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. +// ^^^^^ reference local typeB_289 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. + else if (typeA is reflect.NullableType && typeB is reflect.NullableType) +// ^^^^^ reference local typeA_289 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType# +// ^^^^^ reference local typeB_289 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType# + isSameType(typeA.member, typeB.member) +// ^^^^^^^^^^ reference local isSameType_289 +// ^^^^^ reference local typeA_289 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType#member. +// ^^^^^ reference local typeB_289 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType#member. + else if (typeA is reflect.NothingType && typeB is reflect.NothingType) +// ^^^^^ reference local typeA_289 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NothingType# +// ^^^^^ reference local typeB_289 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NothingType# + true + else if (typeA is reflect.UnknownType && typeB is reflect.UnknownType) +// ^^^^^ reference local typeA_289 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnknownType# +// ^^^^^ reference local typeB_289 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnknownType# + true + else if (typeA is reflect.StringLiteralType && typeB is reflect.StringLiteralType) +// ^^^^^ reference local typeA_289 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType# +// ^^^^^ reference local typeB_289 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType# + typeA.value == typeB.value +// ^^^^^ reference local typeA_289 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType#value. +// ^^^^^ reference local typeB_289 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType#value. + // union types turn into Go's `any`, so we can say that this is always fine. + else if (typeA is reflect.UnionType && typeB is reflect.UnionType) +// ^^^^^ reference local typeA_289 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType# +// ^^^^^ reference local typeB_289 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType# + true + // remaining types: `FunctionType`, `TypeParameter`, `ModuleType`. + // we can actually check if `ModuleType` refers to the same type by checking if the enclosing declaration is the same, + // but we will pretend it is always false for now. + else false + + /// Given a class, return all of its properties, including properties of all inherited classes. + /// + /// Excludes properties that are functions, and any hidden properties. + /// + /// **NOTE**: JSON Schema has a way to combine schemas together using `allOf`. At first glance, this might + /// seem like a good way to model inheritance; the schema is all of the child properties and the parent + /// properties. However, this mechanism breaks if a child class overrides the property of a parent class. + /// If an overridden property is mutually exclusive with the parent property, `allOf` would produce an + /// invalid JSON schema because it is impossible for any object to match all of the specified constraints. + local function getProperties(clazz: reflect.Class): Map = getAllProperties(clazz) +// ^^^^^^^^^^^^^ definition local getProperties_308 +// documentation +// > Given a class, return all of its properties, including properties of all inherited classes. +// > +// > Excludes properties that are functions, and any hidden properties. +// > +// > **NOTE**: JSON Schema has a way to combine schemas together using `allOf`. At first glance, this might +// > seem like a good way to model inheritance; the schema is all of the child properties and the parent +// > properties. However, this mechanism breaks if a child class overrides the property of a parent class. +// > If an overridden property is mutually exclusive with the parent property, `allOf` would produce an +// > invalid JSON schema because it is impossible for any object to match all of the specified constraints. +// ^^^^^ definition local clazz_317 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# +// ^^^^^^^^^^^^^^^^ reference local getAllProperties_322 +// ^^^^^ reference local clazz_317 + .filter((_, prop) -> !prop.modifiers.contains("hidden")) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^ definition local prop_318 +// ^^^^ reference local prop_318 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#modifiers. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). + .filter((_, prop) -> !(prop.type is reflect.FunctionType)) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^ definition local prop_319 +// ^^^^ reference local prop_319 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/FunctionType# + + // noinspection TypeMismatch + local function getAllProperties(clazz: reflect.Class): Map = +// ^^^^^^^^^^^^^^^^ definition local getAllProperties_322 +// ^^^^^ definition local clazz_322 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# + if (clazz.superclass == clazz || clazz.superclass == null) +// ^^^^^ reference local clazz_322 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#superclass. +// ^^^^^ reference local clazz_322 +// ^^^^^ reference local clazz_322 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#superclass. + clazz.properties +// ^^^^^ reference local clazz_322 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#properties. + else + let (superProperties = getAllProperties(clazz.superclass!!)) +// ^^^^^^^^^^^^^^^ definition local superProperties_326 +// ^^^^^^^^^^^^^^^^ reference local getAllProperties_322 +// ^^^^^ reference local clazz_322 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#superclass. + clazz.properties.fold(superProperties, (acc: Map, key: String, prop: reflect.Property) -> +// ^^^^^ reference local clazz_322 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#properties. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#fold(). +// ^^^^^^^^^^^^^^^ reference local superProperties_326 +// ^^^ definition local acc_327 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# +// ^^^ definition local key_327 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ definition local prop_327 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# + // if it's the same type declaration, keep the super property + if (acc.containsKey(key) && isSameType(acc[key].type, prop.type)) acc +// ^^^ reference local acc_327 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#containsKey(). +// ^^^ reference local key_327 +// ^^^^^^^^^^ reference local isSameType_289 +// ^^^ reference local acc_327 +// ^^^ reference local key_327 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^ reference local prop_327 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^ reference local acc_327 + // if the property's type is unknown, keep the super property. + // this might be a property declaration without a new type. + // e.g. `class Foo extends Bar { bar = "mybar" }` + else if (prop.type is reflect.UnknownType) acc +// ^^^^ reference local prop_327 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnknownType# +// ^^^ reference local acc_327 + else acc.put(key, prop) +// ^^^ reference local acc_327 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#put(). +// ^^^ reference local key_327 +// ^^^^ reference local prop_327 + ) + diff --git a/pkl-pantrysnapshot/org.openapis.v3.contrib/examples/Finch.pkl b/pkl-pantrysnapshot/org.openapis.v3.contrib/examples/Finch.pkl new file mode 100755 index 00000000..07fb04a8 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3.contrib/examples/Finch.pkl @@ -0,0 +1,31 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module darwins.Finch +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/Finch.pkl`/ + + /// What is this beak good for? + beakIsGoodFor: "nuts"|"fruits"|"insects" +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/Finch.pkl`/beakIsGoodFor. +//documentation +//> What is this beak good for? + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/Finch.pkl`/output. + renderer = new JsonRenderer {} +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/Finch.pkl`/renderer. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer# + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3.contrib/examples/SampleAPI.pkl b/pkl-pantrysnapshot/org.openapis.v3.contrib/examples/SampleAPI.pkl new file mode 100755 index 00000000..145cf07b --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3.contrib/examples/SampleAPI.pkl @@ -0,0 +1,146 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.openapis.v3_0.examples.SampleAPI +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/ + + amends "@openapi/Document.pkl" + + import "@openapi/Components.pkl" + import "@openapi/HTTPResponse.pkl" + import "../SchemaGenerator.pkl" + + // User schema + local class User { +// ^^^^ definition local User_25 + firstName: String +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/User#firstName. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + middleName: String? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/User#middleName. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + lastName: String +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/User#lastName. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + info { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/info. + title = "Sample API" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/title. + description = "Example API to demonstrate the form of an OpenAPI PKL document" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/description. + version = "0.1.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/version. + } + + servers { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/servers. + // staging + new { + url = "https://staging-api.example.com" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/url. + description = "Staging server" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/description. + } + + // production + new { + url = "https://api.example.com/{basePath}" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/url. + description = "Production server" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/description. + variables { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/variables. + ["basePath"] { + default = "v1" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/default. + } + } + } + } + + paths { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/paths. + ["/users"] { + get { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/get. + summary = "Returns a list of users" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/summary. + description = """ +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/description. + This is an endpoint that returns a list of users from the configured storage backend. + Blah blah blah. + """ + responses { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/responses. + [HTTPResponse.OK] { +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/ +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/OK. + description = "A JSON array of usernames" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/description. + content { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/content. + ["application/json"] { + schema = Components.componentRef("schemas", "UserList") +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/schema. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/componentRef(). + } + } + } + ["4XX"] { + description = "Any client-side error" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/description. + } + } + } + } + } + + // define components + components { +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/components. + schemas { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/schemas. + ["User"] = SchemaGenerator.generate(User) +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/generate(). +// ^^^^ reference local User_25 + ["UserList"] { + type = "array" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/type. + items = Components.componentRef("schemas", "User") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/items. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/componentRef(). + } + } + links { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/links. + ["someLink"] { + requestBody = "$url#/foo/bar" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/requestBody. + } + } + } + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/output. + renderer = new JsonRenderer {} +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SampleAPI.pkl`/renderer. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer# + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3.contrib/examples/SwallowSchema.pkl b/pkl-pantrysnapshot/org.openapis.v3.contrib/examples/SwallowSchema.pkl new file mode 100755 index 00000000..cfeb4275 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3.contrib/examples/SwallowSchema.pkl @@ -0,0 +1,203 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.openapis.v3_0.examples.SwallowSchema +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/ + + import "../SchemaGenerator.pkl" + + /// A friend of a Swallow. + class SwallowFriend { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/SwallowFriend# +// documentation +// > A friend of a Swallow. + /// The name of the friend. + name: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/SwallowFriend#name. +// documentation +// > The name of the friend. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Is this friend also a Swallow? + isSwallow: Boolean +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/SwallowFriend#isSwallow. +// documentation +// > Is this friend also a Swallow? +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Any extra attributes for the friend. + tags: Mapping +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/SwallowFriend#tags. +// documentation +// > Any extra attributes for the friend. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// This is a Swallow + class Swallow { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow# +// documentation +// > This is a Swallow + + /// Does this Swallow have a gulp? + hasGulp: Boolean +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#hasGulp. +// documentation +// > Does this Swallow have a gulp? +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// One of the variants for this swallow. + variants: Listing<"African"|"European"> +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#variants. +// documentation +// > One of the variants for this swallow. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + + /// What is the air speed of this swallow? + airSpeed: Number? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#airSpeed. +// documentation +// > What is the air speed of this swallow? +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + /// Is this Swallow a Duck? + /// + /// This is deprecated because no swallows are ever ducks. + @Deprecated +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Deprecated# + isDuck: Boolean? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#isDuck. +// documentation +// > Is this Swallow a Duck? +// > +// > This is deprecated because no swallows are ever ducks. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// How old is this Swallow? + age: UInt8 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#age. +// documentation +// > How old is this Swallow? +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# + + /// What are the nicknames? + nicknames: Listing +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#nicknames. +// documentation +// > What are the nicknames? +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Who is the best friend of this Swallow? + bestFriend: SwallowFriend +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#bestFriend. +// documentation +// > Who is the best friend of this Swallow? +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/SwallowFriend# + + /// Who are the friends of this Swallow? + friends: Listing +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#friends. +// documentation +// > Who are the friends of this Swallow? +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/SwallowFriend# + + /// Any extra attributes. + tags: Mapping +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#tags. +// documentation +// > Any extra attributes. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The typical size of a flight path of this Swallow. + typicalFlightPathSize: DataSize +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#typicalFlightPathSize. +// documentation +// > The typical size of a flight path of this Swallow. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + + /// This is a list. It really should not be used, but sometimes people make mistakes. Regardless, + /// it should turn into an array type. + list: List +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#list. +// documentation +// > This is a list. It really should not be used, but sometimes people make mistakes. Regardless, +// > it should turn into an array type. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Swoop! + /// + /// This should not appear in the schema output. + swoop: (String) -> String = (input) -> "SWOOP \(input)" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#swoop. +// documentation +// > Swoop! +// > +// > This should not appear in the schema output. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local input_75 +// ^^^^^ reference local input_75 + + /// Swoopwoop! + /// + /// This should also not appear in the schema output. + function swoopwoop() = "swoopwoop!" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#swoopwoop(). +// documentation +// > Swoopwoop! +// > +// > This should also not appear in the schema output. + + /// soar! + /// + /// Don't show me in the schema because I don't show up in any rendered output. + hidden soar: Boolean? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow#soar. +// documentation +// > soar! +// > +// > Don't show me in the schema because I don't show up in any rendered output. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + local generator = new SchemaGenerator { +// ^^^^^^^^^ definition local generator_88 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/ + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/converters. + [DataSize] { +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/type. + description = "A data size description" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/description. + } + } + } + + output = generator.generate(Swallow).output +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/output. +// ^^^^^^^^^ reference local generator_88 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/generate(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. + diff --git a/pkl-pantrysnapshot/org.openapis.v3.contrib/tests/SchemaGenerator.pkl b/pkl-pantrysnapshot/org.openapis.v3.contrib/tests/SchemaGenerator.pkl new file mode 100755 index 00000000..9499ff57 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3.contrib/tests/SchemaGenerator.pkl @@ -0,0 +1,155 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.openapis.v3.contrib.tests.SchemaGenerator +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `tests/SchemaGenerator.pkl`/ + + amends "pkl:test" + + import "fixtures/SelfReference.pkl" + import "../examples/SwallowSchema.pkl" + import "../SchemaGenerator.pkl" + import "../examples/Finch.pkl" + + import "@openapi/Schema.pkl" + + local schema = SchemaGenerator.generate(SwallowSchema.Swallow) +// ^^^^^^ definition local schema_27 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/generate(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow# + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `tests/SchemaGenerator.pkl`/facts. + ["recursive references throw an error"] { + module.catch(() -> SchemaGenerator.generate(SelfReference).output.text) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/generate(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `tests/fixtures/SelfReference.pkl`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + .startsWith("Invalid Schema: Unable to convert a schema that refers to itself.") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + } + ["nullable values show up as nullable"] { + (schema.properties!!["airSpeed"] as Schema).nullable == true +// ^^^^^^ reference local schema_27 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/properties. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/nullable. + } + ["deprecated fields show up as deprecated"] { + (schema.properties!!["isDuck"] as Schema).deprecated == true +// ^^^^^^ reference local schema_27 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/properties. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/deprecated. + } + ["generates basic metadata"] { + schema.title == "Swallow" +// ^^^^^^ reference local schema_27 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/title. + schema.description == "This is a Swallow" +// ^^^^^^ reference local schema_27 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/description. + } + ["listings are encoded as arrays"] { + local nicknameSchema = schema.properties!!["nicknames"] as Schema +// ^^^^^^^^^^^^^^ definition local nicknameSchema_45 +// ^^^^^^ reference local schema_27 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/properties. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + nicknameSchema.type == "array" +// ^^^^^^^^^^^^^^ reference local nicknameSchema_45 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + nicknameSchema.items.type == "string" +// ^^^^^^^^^^^^^^ reference local nicknameSchema_45 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/items. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + } + ["mappings are encoded as objects"] { + local tagsSchema = schema.properties!!["tags"] as Schema +// ^^^^^^^^^^ definition local tagsSchema_50 +// ^^^^^^ reference local schema_27 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/properties. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + tagsSchema.type == "object" +// ^^^^^^^^^^ reference local tagsSchema_50 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + tagsSchema.additionalProperties.type == "string" +// ^^^^^^^^^^ reference local tagsSchema_50 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/additionalProperties. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + } + ["classes are encoded as objects"] { + local friendSchema = schema.properties!!["bestFriend"] as Schema +// ^^^^^^^^^^^^ definition local friendSchema_55 +// ^^^^^^ reference local schema_27 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/properties. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + friendSchema.type == "object" +// ^^^^^^^^^^^^ reference local friendSchema_55 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + friendSchema.properties.toMap().keys == Set("name", "isSwallow", "tags") +// ^^^^^^^^^^^^ reference local friendSchema_55 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/properties. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#keys. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). + } + } + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `tests/SchemaGenerator.pkl`/examples. + ["converts a module"] { + local generator = new SchemaGenerator { +// ^^^^^^^^^ definition local generator_63 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/ + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `tests/SchemaGenerator.pkl`/converters. + [DataSize] { +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + title = "DataSize" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `tests/SchemaGenerator.pkl`/title. + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `tests/SchemaGenerator.pkl`/type. + description = "The size of data in [quantity][unit] representation." +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `tests/SchemaGenerator.pkl`/description. + } + } + } + generator.generate(SwallowSchema.Swallow).output.text +// ^^^^^^^^^ reference local generator_63 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/generate(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/SwallowSchema.pkl`/Swallow# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + ["overwrite a property but inherit its type"] { + local generator = new SchemaGenerator {} +// ^^^^^^^^^ definition local generator_75 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/ + generator.generate(Finch).output.text +// ^^^^^^^^^ reference local generator_75 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `SchemaGenerator.pkl`/generate(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `examples/Finch.pkl`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3.contrib/tests/fixtures/SelfReference.pkl b/pkl-pantrysnapshot/org.openapis.v3.contrib/tests/fixtures/SelfReference.pkl new file mode 100755 index 00000000..4163cb9b --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3.contrib/tests/fixtures/SelfReference.pkl @@ -0,0 +1,24 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module SelfReference +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `tests/fixtures/SelfReference.pkl`/ + + import "SelfReference.pkl" + + myself: SelfReference +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `tests/fixtures/SelfReference.pkl`/myself. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3.contrib 1.1.0 `tests/fixtures/SelfReference.pkl`/ + diff --git a/pkl-pantrysnapshot/org.openapis.v3/BaseParameter.pkl b/pkl-pantrysnapshot/org.openapis.v3/BaseParameter.pkl new file mode 100755 index 00000000..6b091a9d --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/BaseParameter.pkl @@ -0,0 +1,110 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + abstract module org.openapis.v3.BaseParameter +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `BaseParameter.pkl`/ + + /// A brief description of the parameter. + /// + /// This could contain examples of use. CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `BaseParameter.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `BaseParameter.pkl`/description. +//documentation +//> A brief description of the parameter. +//> +//> This could contain examples of use. CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. + /// + /// Default value is false. + deprecated: Boolean? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `BaseParameter.pkl`/deprecated. +//documentation +//> Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. +//> +//> Default value is false. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Sets the ability to pass empty-valued parameters. + /// + /// This is valid only for query parameters and allows sending a parameter with an empty value. Default value is + /// false. If style is used, and if behavior is n/a (cannot be serialized), the value of allowEmptyValue SHALL be + /// ignored. Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later revision. + allowEmptyValue: Boolean? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `BaseParameter.pkl`/allowEmptyValue. +//documentation +//> Sets the ability to pass empty-valued parameters. +//> +//> This is valid only for query parameters and allows sending a parameter with an empty value. Default value is +//> false. If style is used, and if behavior is n/a (cannot be serialized), the value of allowEmptyValue SHALL be +//> ignored. Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later revision. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// When this is true, parameter values of type array or object generate separate parameters for each value of the + /// array or key-value pair of the map. + /// + /// For other types of parameters this property has no effect. When style is form, the default value is true. For all + /// other styles, the default value is false. + explode: Boolean? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `BaseParameter.pkl`/explode. +//documentation +//> When this is true, parameter values of type array or object generate separate parameters for each value of the +//> array or key-value pair of the map. +//> +//> For other types of parameters this property has no effect. When style is form, the default value is true. For all +//> other styles, the default value is false. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Example of the parameter's potential value. The example SHOULD match the specified schema and encoding properties + /// if present. + /// + /// The example field is mutually exclusive of the examples field. Furthermore, if referencing a schema that contains + /// an example, the example value SHALL override the example provided by the schema. To represent examples of media + /// types that cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping + /// where necessary. + example: Any?(!(this != null && examples != null)) +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `BaseParameter.pkl`/example. +//documentation +//> Example of the parameter's potential value. The example SHOULD match the specified schema and encoding properties +//> if present. +//> +//> The example field is mutually exclusive of the examples field. Furthermore, if referencing a schema that contains +//> an example, the example value SHALL override the example provided by the schema. To represent examples of media +//> types that cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping +//> where necessary. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `BaseParameter.pkl`/examples. + + /// Examples of the parameter's potential value. + /// + /// Each example SHOULD contain a value in the correct format as specified in the parameter encoding. The examples + /// field is mutually exclusive of the example field. Furthermore, if referencing a schema that contains an example, + /// the examples value SHALL override the example provided by the schema. + examples: Mapping? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `BaseParameter.pkl`/examples. +//documentation +//> Examples of the parameter's potential value. +//> +//> Each example SHOULD contain a value in the correct format as specified in the parameter encoding. The examples +//> field is mutually exclusive of the example field. Furthermore, if referencing a schema that contains an example, +//> the examples value SHALL override the example provided by the schema. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Components.pkl b/pkl-pantrysnapshot/org.openapis.v3/Components.pkl new file mode 100755 index 00000000..1e293d11 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Components.pkl @@ -0,0 +1,163 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Holds a set of reusable objects for different aspects of the OAS. + /// + /// All objects defined within the components object will have no effect on the API unless they are explicitly + /// referenced from properties outside the components object. + module org.openapis.v3.Components +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ + + import "expressions.pkl" + import "Example.pkl" + import "Header.pkl" + import "Link.pkl" + import "Parameter.pkl" + import "Reference.pkl" + import "RequestBody.pkl" + import "Response.pkl" + import "Schema.pkl" + import "SecurityScheme.pkl" + import "PathItem.pkl" + + /// Component mapping key type used to reference all component values. + typealias ComponentKey = String(matches(Regex(#"[a-zA-Z0-9.\-_]+"#))) +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentKey# +// documentation +// > Component mapping key type used to reference all component values. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + + /// Component type name for use with component reference helpers. + typealias ComponentType = "schemas"|"responses"|"parameters"|"examples"|"requestBodies"|"headers"|"links" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentType# +// documentation +// > Component type name for use with component reference helpers. + + /// An object to hold reusable Schema Objects. + schemas: Mapping? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/schemas. +//documentation +//> An object to hold reusable Schema Objects. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentKey# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// An object to hold reusable Response Objects. + responses: Mapping? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/responses. +//documentation +//> An object to hold reusable Response Objects. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentKey# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Response.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// An object to hold reusable Parameter Objects. + parameters: Mapping? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/parameters. +//documentation +//> An object to hold reusable Parameter Objects. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentKey# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// An object to hold reusable Example Objects. + examples: Mapping? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/examples. +//documentation +//> An object to hold reusable Example Objects. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentKey# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Example.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// An object to hold reusable RequestBody Objects. + requestBodies: Mapping? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/requestBodies. +//documentation +//> An object to hold reusable RequestBody Objects. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentKey# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `RequestBody.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// An object to hold reusable Header Objects. + headers: Mapping? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/headers. +//documentation +//> An object to hold reusable Header Objects. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentKey# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Header.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// An object to hold reusable Security Scheme Objects. + securitySchemes: Mapping? +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/securitySchemes. +//documentation +//> An object to hold reusable Security Scheme Objects. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentKey# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// An object to hold reusable Link Objects. + links: Mapping? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/links. +//documentation +//> An object to hold reusable Link Objects. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentKey# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Link.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// An object to hold reusable Callback Objects. + callbacks: Mapping|Reference>? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/callbacks. +//documentation +//> An object to hold reusable Callback Objects. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentKey# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// Component reference helper function. This reference will point to the named component in the local document's + /// "components" fields. + function componentRef(type: ComponentType, name: String): Reference = +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/componentRef(). +// documentation +// > Component reference helper function. This reference will point to the named component in the local document's +// > "components" fields. +// ^^^^ definition local type_69 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ComponentType# +// ^^^^ definition local name_69 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + // TODO: can we throw an error if the referenced component does not exist? This would be extremely useful. + // We may need to check for reference consistencey in the render step. + new Reference { +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + `$ref` = "#/components/\(type)/\(name)" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/$ref. +// ^^^^ reference local type_69 +// ^^^^ reference local name_69 + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Contact.pkl b/pkl-pantrysnapshot/org.openapis.v3/Contact.pkl new file mode 100755 index 00000000..e307d877 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Contact.pkl @@ -0,0 +1,44 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Contact information for the exposed API. + module org.openapis.v3.Contact +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Contact.pkl`/ + + /// The identifying name of the contact person/organization. + name: String? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Contact.pkl`/name. +//documentation +//> The identifying name of the contact person/organization. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The URL pointing to the contact information. MUST be in the format of a URL. + url: Uri? +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Contact.pkl`/url. +//documentation +//> The URL pointing to the contact information. MUST be in the format of a URL. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + + /// The email address of the contact person/organization. + /// + /// MUST be in the format of an email address. + email: String? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Contact.pkl`/email. +//documentation +//> The email address of the contact person/organization. +//> +//> MUST be in the format of an email address. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Document.pkl b/pkl-pantrysnapshot/org.openapis.v3/Document.pkl new file mode 100755 index 00000000..2f6f879a --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Document.pkl @@ -0,0 +1,183 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + open module org.openapis.v3.Document +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/ + + import "Components.pkl" + import "Extension.pkl" + import "ExternalDocs.pkl" + import "Info.pkl" + import "PathItem.pkl" + import "Reference.pkl" as _Reference + import "Security.pkl" + import "Server.pkl" + import "Tag.pkl" + + /// This string MUST be the semantic version number of the OpenAPI Specification version that the OpenAPI document + /// uses. + /// + /// The openapi field SHOULD be used by tooling specifications and clients to interpret the OpenAPI document. This is + /// not related to the API info.version string. The default value corresponds to the version of the spec we've + /// implemented in this package. + /// + /// Since this library specifically follows version 3.0.3 of the OpenAPI spec, this value cannot change unless this + /// library is updated to implement a later version. + fixed openapi = "3.0.3" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/openapi. +// documentation +// > This string MUST be the semantic version number of the OpenAPI Specification version that the OpenAPI document +// > uses. +// > +// > The openapi field SHOULD be used by tooling specifications and clients to interpret the OpenAPI document. This is +// > not related to the API info.version string. The default value corresponds to the version of the spec we've +// > implemented in this package. +// > +// > Since this library specifically follows version 3.0.3 of the OpenAPI spec, this value cannot change unless this +// > library is updated to implement a later version. + + /// Provides metadata about the API. + /// + /// The metadata MAY be used by tooling as required. + info: Info +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/info. +//documentation +//> Provides metadata about the API. +//> +//> The metadata MAY be used by tooling as required. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Info.pkl`/ + + /// An array of Server Objects, which provide connectivity information to a target server. + /// + /// If the servers property is not provided, or is an empty array, the default value would be a Server Object with a + /// url value of /. + servers: Listing? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/servers. +//documentation +//> An array of Server Objects, which provide connectivity information to a target server. +//> +//> If the servers property is not provided, or is an empty array, the default value would be a Server Object with a +//> url value of /. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Server.pkl`/ + + /// The available paths and operations for the API. + /// + /// Contains relative paths to an individual endpoint. The field name MUST begin with a forward slash (/). The path is + /// appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct + /// the full URL. Path templating is allowed. + /// + /// When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. + /// Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical. + /// + /// In case of ambiguous matching, it's up to the tooling to decide which one to use. + paths: Mapping +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/paths. +//documentation +//> The available paths and operations for the API. +//> +//> Contains relative paths to an individual endpoint. The field name MUST begin with a forward slash (/). The path is +//> appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct +//> the full URL. Path templating is allowed. +//> +//> When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. +//> Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical. +//> +//> In case of ambiguous matching, it's up to the tooling to decide which one to use. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/ + + /// An element to hold various schemas for the specification. + components: Components? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/components. +//documentation +//> An element to hold various schemas for the specification. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Components.pkl`/ + + /// A declaration of which security mechanisms can be used across the API. + /// + /// The list of values includes alternative security requirement objects that can be used. Only one of the security + /// requirement objects need to be satisfied to authorize a request. Individual operations can override this + /// definition. To make security optional, an empty security requirement ({}) can be included in the array. + security: Listing? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/security. +//documentation +//> A declaration of which security mechanisms can be used across the API. +//> +//> The list of values includes alternative security requirement objects that can be used. Only one of the security +//> requirement objects need to be satisfied to authorize a request. Individual operations can override this +//> definition. To make security optional, an empty security requirement ({}) can be included in the array. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Security.pkl`/Requirement# + + /// A list of tags used by the specification with additional metadata. + /// + /// The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by + /// the Operation Object must be declared. The tags that are not declared MAY be organized randomly or based on the + /// tools' logic. Each tag name in the list MUST be unique. + tags: Listing(isDistinct)? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/tags. +//documentation +//> A list of tags used by the specification with additional metadata. +//> +//> The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by +//> the Operation Object must be declared. The tags that are not declared MAY be organized randomly or based on the +//> tools' logic. Each tag name in the list MUST be unique. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Tag.pkl`/ +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. + + /// Additional external documentation. + externalDocs: ExternalDocs? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/externalDocs. +//documentation +//> Additional external documentation. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ExternalDocs.pkl`/ + + // re-export types so they are available without import + typealias Reference = _Reference +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/output. + // noinspection TypeMismatch + local const format: "json"|"yaml" = read?("prop:pkl.outputFormat") ?? "json" +// ^^^^^^ definition local format_87 + + local const renderers: Mapping = new { +// ^^^^^^^^^ definition local renderers_89 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer# + ["json"] = new JsonRenderer {} +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer# + ["yaml"] = new YamlRenderer {} +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/YamlRenderer# + } + + renderer = (renderers[format]) { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/renderer. +// ^^^^^^^^^ reference local renderers_89 +// ^^^^^^ reference local format_87 + converters = Extension.converters +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/converters. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Extension.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Extension.pkl`/converters. + } + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Encoding.pkl b/pkl-pantrysnapshot/org.openapis.v3/Encoding.pkl new file mode 100755 index 00000000..5bdacfcc --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Encoding.pkl @@ -0,0 +1,104 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.openapis.v3.Encoding +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Encoding.pkl`/ + + import "Header.pkl" + import "Reference.pkl" + import "MediaType.pkl" + + /// The Content-Type for encoding a specific property. + /// + /// Default value depends on the property type: for string with format being binary – application/octet-stream; for + /// other primitive types – text/plain; for object - application/json; for array – the default is defined based on + /// the inner type. The value can be a specific media type (e.g. application/json), a wildcard media type + /// (e.g. image/*), or a comma-separated list of the two types. + contentType: MediaType.MediaTypeName? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Encoding.pkl`/contentType. +//documentation +//> The Content-Type for encoding a specific property. +//> +//> Default value depends on the property type: for string with format being binary – application/octet-stream; for +//> other primitive types – text/plain; for object - application/json; for array – the default is defined based on +//> the inner type. The value can be a specific media type (e.g. application/json), a wildcard media type +//> (e.g. image/*), or a comma-separated list of the two types. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/MediaTypeName# + + /// A map allowing additional information to be provided as headers, for + /// example Content-Disposition. + /// + /// Content-Type is described separately and SHALL be ignored in this section. This property SHALL be ignored if the + /// request body media type is not a multipart. + headers: Mapping? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Encoding.pkl`/headers. +//documentation +//> A map allowing additional information to be provided as headers, for +//> example Content-Disposition. +//> +//> Content-Type is described separately and SHALL be ignored in this section. This property SHALL be ignored if the +//> request body media type is not a multipart. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Header.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// Describes how a specific property value will be serialized depending on its type. + /// + /// See Parameter Object for details on the style property. The behavior follows the same values as query parameters, + /// including default values. This property SHALL be ignored if the request body media type is not + /// application/x-www-form-urlencoded. + style: String? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Encoding.pkl`/style. +//documentation +//> Describes how a specific property value will be serialized depending on its type. +//> +//> See Parameter Object for details on the style property. The behavior follows the same values as query parameters, +//> including default values. This property SHALL be ignored if the request body media type is not +//> application/x-www-form-urlencoded. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// When this is true, property values of type array or object generate separate parameters for each value of the + /// array, or key-value-pair of the map. + /// + /// For other types of properties this property has no effect. When style is form, the default value is true. For all + /// other styles, the default value is false. This property SHALL be ignored if the request body media type is not + /// application/x-www-form-urlencoded. + explode: Boolean? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Encoding.pkl`/explode. +//documentation +//> When this is true, property values of type array or object generate separate parameters for each value of the +//> array, or key-value-pair of the map. +//> +//> For other types of properties this property has no effect. When style is form, the default value is true. For all +//> other styles, the default value is false. This property SHALL be ignored if the request body media type is not +//> application/x-www-form-urlencoded. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Determines whether the parameter value SHOULD allow reserved characters, as defined by RFC3986 :/?#[]@!$&'()*+,;= + /// to be included without percent-encoding. + /// + /// The default value is false. This property SHALL be ignored if the request body media type is not + /// application/x-www-form-urlencoded. + allowReserved: Boolean? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Encoding.pkl`/allowReserved. +//documentation +//> Determines whether the parameter value SHOULD allow reserved characters, as defined by RFC3986 :/?#[]@!$&'()*+,;= +//> to be included without percent-encoding. +//> +//> The default value is false. This property SHALL be ignored if the request body media type is not +//> application/x-www-form-urlencoded. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Example.pkl b/pkl-pantrysnapshot/org.openapis.v3/Example.pkl new file mode 100755 index 00000000..c8219100 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Example.pkl @@ -0,0 +1,66 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.openapis.v3.Example +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Example.pkl`/ + + /// Short description for the example + summary: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Example.pkl`/summary. +//documentation +//> Short description for the example +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Long description for the example. + /// + /// CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Example.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Example.pkl`/description. +//documentation +//> Long description for the example. +//> +//> CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Embedded literal example. The value field and externalValue field are mutually exclusive. + /// + /// To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to + /// contain the example, escaping where necessary. + value: Any?(!(this != null && externalValue != null)) +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Example.pkl`/value. +//documentation +//> Embedded literal example. The value field and externalValue field are mutually exclusive. +//> +//> To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to +//> contain the example, escaping where necessary. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Example.pkl`/externalValue. + + /// A URL that points to the literal example. + /// + /// This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The + /// value field and externalValue field are mutually exclusive. + externalValue: Uri? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Example.pkl`/externalValue. +//documentation +//> A URL that points to the literal example. +//> +//> This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The +//> value field and externalValue field are mutually exclusive. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Extension.pkl b/pkl-pantrysnapshot/org.openapis.v3/Extension.pkl new file mode 100755 index 00000000..d0ea667d --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Extension.pkl @@ -0,0 +1,65 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The Extension object represents the possibility of adding additional data + /// to extend the specification at certain points. + /// + /// + module org.openapis.v3.Extension +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Extension.pkl`/ + + import "Info.pkl" + import "SecurityScheme.pkl" + import "Schema.pkl" + + /// A string representing the key of an extension. + typealias Key = String(startsWith("x-"), length > 2) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Extension.pkl`/Key# +// documentation +// > A string representing the key of an extension. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + + hidden converters: Mapping Any> = new { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Extension.pkl`/converters. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + local extractExtensions = (it: Module) -> it.toMap() + (it.getProperty("extensions") ?? Map()).toMap() +// ^^^^^^^^^^^^^^^^^ definition local extractExtensions_30 +// ^^ definition local it_30 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module# +// ^^ reference local it_30 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). +// ^^ reference local it_30 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#getProperty(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMap(). + [Schema.getClass()] = extractExtensions +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^^^^^^^^ reference local extractExtensions_30 + [SecurityScheme.getClass()] = extractExtensions +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^^^^^^^^ reference local extractExtensions_30 + [Info.getClass()] = extractExtensions +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Info.pkl`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^^^^^^^^ reference local extractExtensions_30 + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3/ExternalDocs.pkl b/pkl-pantrysnapshot/org.openapis.v3/ExternalDocs.pkl new file mode 100755 index 00000000..10db3a8f --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/ExternalDocs.pkl @@ -0,0 +1,44 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Allows referencing an external resource for extended documentation. + module org.openapis.v3.ExternalDocs +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ExternalDocs.pkl`/ + + /// A short description of the target documentation. + /// + /// CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ExternalDocs.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ExternalDocs.pkl`/description. +//documentation +//> A short description of the target documentation. +//> +//> CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The URL for the target documentation. + /// + /// Value MUST be in the format of a URL. + url: Uri? +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ExternalDocs.pkl`/url. +//documentation +//> The URL for the target documentation. +//> +//> Value MUST be in the format of a URL. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/HTTPResponse.pkl b/pkl-pantrysnapshot/org.openapis.v3/HTTPResponse.pkl new file mode 100755 index 00000000..909baeff --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/HTTPResponse.pkl @@ -0,0 +1,625 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Describes a single response from an API Operation, including design-time, static links to operations based on the + /// response. + module org.openapis.v3.HTTPResponse +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/ + + /// String matching a given standard HTTP response code. + /// + /// This typealias allows us to restrict API definitions to responding to HTTP response codes that actually exist in + /// the HTTP specification. + /// + /// Context: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status + typealias Code = +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Code# +// documentation +// > String matching a given standard HTTP response code. +// > +// > This typealias allows us to restrict API definitions to responding to HTTP response codes that actually exist in +// > the HTTP specification. +// > +// > Context: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status + // 1xx + "100"|"101"|"102"|"103"| + // 2xx + "200"|"201"|"202"|"203"|"204"|"205"|"206"|"207"|"208"|"226"| + // 3xx + "300"|"301"|"302"|"303"|"304"|"305"|"307"|"308"| + // 4xx + "400"|"401"|"402"|"403"|"404"|"405"|"406"|"407"|"408"|"409"|"410"|"411"|"412"|"413"|"414"|"415"|"416"|"417"|"418"| + "421"|"422"|"423"|"424"|"425"|"426"|"427"|"428"|"429"|"431"|"451"| + // 5xx + "500"|"501"|"502"|"503"|"504"|"505"|"506"|"507"|"508"|"510"|"511" + + /// Only these wildcard strings are allowed to be used as operation response + /// keys. + typealias CodeWildcard = "1XX"|"2XX"|"3XX"|"4XX"|"5XX" +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/CodeWildcard# +// documentation +// > Only these wildcard strings are allowed to be used as operation response +// > keys. + + /// This interim response indicates that the client should continue the request or ignore the response if the request + /// is already finished. + const Continue: "100" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Continue. +// documentation +// > This interim response indicates that the client should continue the request or ignore the response if the request +// > is already finished. + + /// This code is sent in response to an Upgrade request header from the client and indicates the protocol the server + /// is switching to. + const SwitchingProtocols: "101" +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/SwitchingProtocols. +// documentation +// > This code is sent in response to an Upgrade request header from the client and indicates the protocol the server +// > is switching to. + + /// This code indicates that the server has received and is processing the request, but no response is available yet. + const Processing: "102" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Processing. +// documentation +// > This code indicates that the server has received and is processing the request, but no response is available yet. + + /// This status code is primarily intended to be used with the Link header, letting the user agent start preloading + /// resources while the server prepares a response or preconnect to an origin from which the page will need resources. + const EarlyHints: "103" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/EarlyHints. +// documentation +// > This status code is primarily intended to be used with the Link header, letting the user agent start preloading +// > resources while the server prepares a response or preconnect to an origin from which the page will need resources. + + /// The request succeeded. The result meaning of "success" depends on the HTTP method: + /// + /// * GET: The resource has been fetched and transmitted in the message body. + /// * HEAD: The representation headers are included in the response without any message body. + /// * PUT or POST: The resource describing the result of the action is transmitted in the message body. + /// * TRACE: The message body contains the request message as received by the server. + const OK: "200" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/OK. +// documentation +// > The request succeeded. The result meaning of "success" depends on the HTTP method: +// > +// > * GET: The resource has been fetched and transmitted in the message body. +// > * HEAD: The representation headers are included in the response without any message body. +// > * PUT or POST: The resource describing the result of the action is transmitted in the message body. +// > * TRACE: The message body contains the request message as received by the server. + + /// The request succeeded, and a new resource was created as a result. + /// + /// This is typically the response sent after POST requests, or some PUT requests. + const Created: "201" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Created. +// documentation +// > The request succeeded, and a new resource was created as a result. +// > +// > This is typically the response sent after POST requests, or some PUT requests. + + /// The request has been received but not yet acted upon. It is noncommittal, since there is no way in HTTP to later + /// send an asynchronous response indicating the outcome of the request. + /// + /// It is intended for cases where another process or server handles the request, or for batch processing. + const Accepted: "202" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Accepted. +// documentation +// > The request has been received but not yet acted upon. It is noncommittal, since there is no way in HTTP to later +// > send an asynchronous response indicating the outcome of the request. +// > +// > It is intended for cases where another process or server handles the request, or for batch processing. + + /// This response code means the returned metadata is not exactly the same as is available from the origin server, but + /// is collected from a local or a third-party copy. This is mostly used for mirrors or backups of another resource. + /// + /// Except for that specific case, the 200 OK response is preferred to this status. + const NonAuthoritativeInformation: "203" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/NonAuthoritativeInformation. +// documentation +// > This response code means the returned metadata is not exactly the same as is available from the origin server, but +// > is collected from a local or a third-party copy. This is mostly used for mirrors or backups of another resource. +// > +// > Except for that specific case, the 200 OK response is preferred to this status. + + /// There is no content to send for this request, but the headers may be useful. + /// + /// The user agent may update its cached headers for this resource with the new ones. + const NoContent: "204" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/NoContent. +// documentation +// > There is no content to send for this request, but the headers may be useful. +// > +// > The user agent may update its cached headers for this resource with the new ones. + + /// Tells the user agent to reset the document which sent this request. + const ResetContent: "205" +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/ResetContent. +// documentation +// > Tells the user agent to reset the document which sent this request. + + /// This response code is used when the Range header is sent from the client to request only part of a resource. + const PartialContent: "206" +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/PartialContent. +// documentation +// > This response code is used when the Range header is sent from the client to request only part of a resource. + + /// Conveys information about multiple resources, for situations where multiple status codes might be appropriate. + const MultiStatus: "207" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/MultiStatus. +// documentation +// > Conveys information about multiple resources, for situations where multiple status codes might be appropriate. + + /// Used inside a response element to avoid repeatedly enumerating the internal members of multiple + /// bindings to the same collection. + const AlreadyReported: "208" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/AlreadyReported. +// documentation +// > Used inside a response element to avoid repeatedly enumerating the internal members of multiple +// > bindings to the same collection. + + /// The server has fulfilled a GET request for the resource, and the response is a representation of the result of + /// one or more instance-manipulations applied to the current instance. + const IMUsed: "226" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/IMUsed. +// documentation +// > The server has fulfilled a GET request for the resource, and the response is a representation of the result of +// > one or more instance-manipulations applied to the current instance. + + /// The request has more than one possible response. The user agent or user should choose one of them. + /// + /// There is no standardized way of choosing one of the responses, but HTML links to the possibilities are recommended + /// so the user can pick. + const MultipleChoices: "300" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/MultipleChoices. +// documentation +// > The request has more than one possible response. The user agent or user should choose one of them. +// > +// > There is no standardized way of choosing one of the responses, but HTML links to the possibilities are recommended +// > so the user can pick. + + /// The URL of the requested resource has been changed permanently. + /// + /// The new URL is given in the response. + const MovedPermanently: "301" +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/MovedPermanently. +// documentation +// > The URL of the requested resource has been changed permanently. +// > +// > The new URL is given in the response. + + /// This response code means that the URI of requested resource has been changed temporarily. + /// + /// Further changes in the URI might be made in the future. Therefore, this same URI should be used by the client in + /// future requests. + const Found: "302" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Found. +// documentation +// > This response code means that the URI of requested resource has been changed temporarily. +// > +// > Further changes in the URI might be made in the future. Therefore, this same URI should be used by the client in +// > future requests. + + /// The server sent this response to direct the client to get the requested resource at another URI with a GET request. + const SeeOther: "303" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/SeeOther. +// documentation +// > The server sent this response to direct the client to get the requested resource at another URI with a GET request. + + /// This is used for caching purposes. + /// + /// It tells the client that the response has not been modified, so the client can continue to use the same cached + /// version of the response. + const NotModified: "304" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/NotModified. +// documentation +// > This is used for caching purposes. +// > +// > It tells the client that the response has not been modified, so the client can continue to use the same cached +// > version of the response. + + /// Defined in a previous version of the HTTP specification to indicate that a requested response must be accessed by a + /// proxy. + /// + /// It has been deprecated due to security concerns regarding in-band configuration of a proxy. + const UseProxy: "305" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/UseProxy. +// documentation +// > Defined in a previous version of the HTTP specification to indicate that a requested response must be accessed by a +// > proxy. +// > +// > It has been deprecated due to security concerns regarding in-band configuration of a proxy. + + /// The server sends this response to direct the client to get the requested resource at another URI with the same + /// method that was used in the prior request. + /// + /// This has the same semantics as the 302 Found HTTP response code, with the exception that the user agent must not + /// change the HTTP method used: if a POST was used in the first request, a POST must be used in the second request. + const TemporaryRedirect: "307" +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/TemporaryRedirect. +// documentation +// > The server sends this response to direct the client to get the requested resource at another URI with the same +// > method that was used in the prior request. +// > +// > This has the same semantics as the 302 Found HTTP response code, with the exception that the user agent must not +// > change the HTTP method used: if a POST was used in the first request, a POST must be used in the second request. + + /// This means that the resource is now permanently located at another URI, specified by the Location: HTTP Response + /// header. + /// + /// This has the same semantics as the 301 Moved Permanently HTTP response code, with the exception that the user agent + /// must not change the HTTP method used: if a POST was used in the first request, a POST must be used in the second + /// request. + const PermanentRedirect: "308" +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/PermanentRedirect. +// documentation +// > This means that the resource is now permanently located at another URI, specified by the Location: HTTP Response +// > header. +// > +// > This has the same semantics as the 301 Moved Permanently HTTP response code, with the exception that the user agent +// > must not change the HTTP method used: if a POST was used in the first request, a POST must be used in the second +// > request. + + /// The server cannot or will not process the request due to something that is perceived to be a client error (e.g., + /// malformed request syntax, invalid request message framing, or deceptive request routing). + const BadRequest: "400" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/BadRequest. +// documentation +// > The server cannot or will not process the request due to something that is perceived to be a client error (e.g., +// > malformed request syntax, invalid request message framing, or deceptive request routing). + + /// Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". + /// + /// That is, the client must authenticate itself to get the requested response. + const Unauthorized: "401" +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Unauthorized. +// documentation +// > Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". +// > +// > That is, the client must authenticate itself to get the requested response. + + /// This response code is reserved for future use. + /// + /// The initial aim for creating this code was using it for digital payment systems, however this status code is used + /// very rarely and no standard convention exists. + const PaymentRequired: "402" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/PaymentRequired. +// documentation +// > This response code is reserved for future use. +// > +// > The initial aim for creating this code was using it for digital payment systems, however this status code is used +// > very rarely and no standard convention exists. + + /// The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to + /// give the requested resource. + /// + /// Unlike 401 Unauthorized, the client's identity is known to the server. + const Forbidden: "403" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Forbidden. +// documentation +// > The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to +// > give the requested resource. +// > +// > Unlike 401 Unauthorized, the client's identity is known to the server. + + /// The server cannot find the requested resource. + /// + /// In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but + /// the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the + /// existence of a resource from an unauthorized client. This response code is probably the most well known due to + /// its frequent occurrence on the web. + const NotFound: "404" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/NotFound. +// documentation +// > The server cannot find the requested resource. +// > +// > In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but +// > the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the +// > existence of a resource from an unauthorized client. This response code is probably the most well known due to +// > its frequent occurrence on the web. + + /// The request method is known by the server but is not supported by the target resource. + /// + /// For example, an API may not allow calling DELETE to remove a resource. + const MethodNotAllowed: "405" +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/MethodNotAllowed. +// documentation +// > The request method is known by the server but is not supported by the target resource. +// > +// > For example, an API may not allow calling DELETE to remove a resource. + + /// This response is sent when the web server, after performing server-driven content negotiation, doesn't find any + /// content that conforms to the criteria given by the user agent. + const NotAcceptable: "406" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/NotAcceptable. +// documentation +// > This response is sent when the web server, after performing server-driven content negotiation, doesn't find any +// > content that conforms to the criteria given by the user agent. + + /// This is similar to 401 Unauthorized but authentication is needed to be done by a proxy. + const ProxyAuthenticationRequired: "407" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/ProxyAuthenticationRequired. +// documentation +// > This is similar to 401 Unauthorized but authentication is needed to be done by a proxy. + + /// This response is sent on an idle connection by some servers, even without any previous request by the client. + /// + /// It means that the server would like to shut down this unused connection. This response is used much more since some + /// browsers, like Chrome, Firefox 27+, or IE9, use HTTP pre-connection mechanisms to speed up surfing. Also note that + /// some servers merely shut down the connection without sending this message. + const RequestTimeout: "408" +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/RequestTimeout. +// documentation +// > This response is sent on an idle connection by some servers, even without any previous request by the client. +// > +// > It means that the server would like to shut down this unused connection. This response is used much more since some +// > browsers, like Chrome, Firefox 27+, or IE9, use HTTP pre-connection mechanisms to speed up surfing. Also note that +// > some servers merely shut down the connection without sending this message. + + /// This response is sent when a request conflicts with the current state of the server. + const Conflict: "409" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Conflict. +// documentation +// > This response is sent when a request conflicts with the current state of the server. + + /// This response is sent when the requested content has been permanently deleted from server, with no forwarding + /// address. + /// + /// Clients are expected to remove their caches and links to the resource. The HTTP specification intends this status + /// code to be used for "limited-time, promotional services". APIs should not feel compelled to indicate resources that + /// have been deleted with this status code. + const Gone: "410" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Gone. +// documentation +// > This response is sent when the requested content has been permanently deleted from server, with no forwarding +// > address. +// > +// > Clients are expected to remove their caches and links to the resource. The HTTP specification intends this status +// > code to be used for "limited-time, promotional services". APIs should not feel compelled to indicate resources that +// > have been deleted with this status code. + + /// Server rejected the request because the Content-Length header field is not defined and the server requires it. + const LengthRequired: "411" +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/LengthRequired. +// documentation +// > Server rejected the request because the Content-Length header field is not defined and the server requires it. + + /// The client has indicated preconditions in its headers which the server does not meet. + const PreconditionFailed: "412" +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/PreconditionFailed. +// documentation +// > The client has indicated preconditions in its headers which the server does not meet. + + /// Request entity is larger than limits defined by server. + /// + /// The server might close the connection or return an Retry-After header field. + const PayloadTooLarge: "413" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/PayloadTooLarge. +// documentation +// > Request entity is larger than limits defined by server. +// > +// > The server might close the connection or return an Retry-After header field. + + /// The URI requested by the client is longer than the server is willing to interpret. + const URITooLong: "414" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/URITooLong. +// documentation +// > The URI requested by the client is longer than the server is willing to interpret. + + /// The media format of the requested data is not supported by the server, so the server is rejecting the request. + const UnsupportedMediaType: "415" +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/UnsupportedMediaType. +// documentation +// > The media format of the requested data is not supported by the server, so the server is rejecting the request. + + /// The range specified by the Range header field in the request cannot be fulfilled. + /// + /// It's possible that the range is outside the size of the target URI's data. + const RangeNotSatisfiable: "416" +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/RangeNotSatisfiable. +// documentation +// > The range specified by the Range header field in the request cannot be fulfilled. +// > +// > It's possible that the range is outside the size of the target URI's data. + + /// This response code means the expectation indicated by the Expect request header field cannot be met by the server. + const ExpectationFailed: "417" +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/ExpectationFailed. +// documentation +// > This response code means the expectation indicated by the Expect request header field cannot be met by the server. + + /// The server refuses the attempt to brew coffee with a teapot. + /// + /// Context: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/418 + const Teapot: "418" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Teapot. +// documentation +// > The server refuses the attempt to brew coffee with a teapot. +// > +// > Context: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/418 + + /// The request was directed at a server that is not able to produce a response. + /// + /// This can be sent by a server that is not configured to produce responses for the combination of scheme and + /// authority that are included in the request URI. + const MisdirectedRequest: "421" +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/MisdirectedRequest. +// documentation +// > The request was directed at a server that is not able to produce a response. +// > +// > This can be sent by a server that is not configured to produce responses for the combination of scheme and +// > authority that are included in the request URI. + + /// The request was well-formed but was unable to be followed due to semantic errors. + const UnprocessableContent: "422" +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/UnprocessableContent. +// documentation +// > The request was well-formed but was unable to be followed due to semantic errors. + + /// The resource that is being accessed is locked. + const Locked: "423" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Locked. +// documentation +// > The resource that is being accessed is locked. + + /// The request failed due to failure of a previous request. + const FailedDependency: "424" +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/FailedDependency. +// documentation +// > The request failed due to failure of a previous request. + + /// Indicates that the server is unwilling to risk processing a request that might be replayed. + const TooEarly: "425" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/TooEarly. +// documentation +// > Indicates that the server is unwilling to risk processing a request that might be replayed. + + /// The server refuses to perform the request using the current protocol but might be willing to do so after the + /// client upgrades to a different protocol. + /// + /// The server sends an Upgrade header in a 426 response to indicate the required protocol(s). + const UpgradeRequired: "426" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/UpgradeRequired. +// documentation +// > The server refuses to perform the request using the current protocol but might be willing to do so after the +// > client upgrades to a different protocol. +// > +// > The server sends an Upgrade header in a 426 response to indicate the required protocol(s). + + /// The origin server requires the request to be conditional. + /// + /// This response is intended to prevent the 'lost update' problem, where a client GETs a resource's state, modifies it + /// and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a + /// conflict. + const PreconditionRequired: "428" +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/PreconditionRequired. +// documentation +// > The origin server requires the request to be conditional. +// > +// > This response is intended to prevent the 'lost update' problem, where a client GETs a resource's state, modifies it +// > and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a +// > conflict. + + /// The user has sent too many requests in a given amount of time ("rate limiting"). + const TooManyRequests: "429" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/TooManyRequests. +// documentation +// > The user has sent too many requests in a given amount of time ("rate limiting"). + + /// The server is unwilling to process the request because its header fields are too large. + /// + /// The request may be resubmitted after reducing the size of the request header fields. + const RequestHeaderFieldsTooLarge: "431" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/RequestHeaderFieldsTooLarge. +// documentation +// > The server is unwilling to process the request because its header fields are too large. +// > +// > The request may be resubmitted after reducing the size of the request header fields. + + /// The user agent requested a resource that cannot legally be provided, such as a web page censored by a government. + const UnavailableForLegalReasons: "451" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/UnavailableForLegalReasons. +// documentation +// > The user agent requested a resource that cannot legally be provided, such as a web page censored by a government. + + /// The server has encountered a situation it does not know how to handle. + const InternalServerError: "500" +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/InternalServerError. +// documentation +// > The server has encountered a situation it does not know how to handle. + + /// The request method is not supported by the server and cannot be handled. + /// + /// The only methods that servers are required to support (and therefore that must not return this code) are GET and + /// HEAD. + const NotImplemented: "501" +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/NotImplemented. +// documentation +// > The request method is not supported by the server and cannot be handled. +// > +// > The only methods that servers are required to support (and therefore that must not return this code) are GET and +// > HEAD. + + /// This error response means that the server, while working as a gateway to get a response needed to handle the + /// request, got an invalid response. + const BadGateway: "502" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/BadGateway. +// documentation +// > This error response means that the server, while working as a gateway to get a response needed to handle the +// > request, got an invalid response. + + /// The server is not ready to handle the request. + /// + /// Common causes are a server that is down for maintenance or that is overloaded. Note that together with this + /// response, a user-friendly page explaining the problem should be sent. This response should be used for temporary + /// conditions and the Retry-After HTTP header should, if possible, contain the estimated time before the recovery of + /// the service. The webmaster must also take care about the caching-related headers that are sent along with this + /// response, as these temporary condition responses should usually not be cached. + const ServiceUnavailable: "503" +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/ServiceUnavailable. +// documentation +// > The server is not ready to handle the request. +// > +// > Common causes are a server that is down for maintenance or that is overloaded. Note that together with this +// > response, a user-friendly page explaining the problem should be sent. This response should be used for temporary +// > conditions and the Retry-After HTTP header should, if possible, contain the estimated time before the recovery of +// > the service. The webmaster must also take care about the caching-related headers that are sent along with this +// > response, as these temporary condition responses should usually not be cached. + + /// This error response is given when the server is acting as a gateway and cannot get a response in time. + const GatewayTimeout: "504" +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/GatewayTimeout. +// documentation +// > This error response is given when the server is acting as a gateway and cannot get a response in time. + + /// The HTTP version used in the request is not supported by the server. + const HTTPVersionNotSupported: "505" +// ^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/HTTPVersionNotSupported. +// documentation +// > The HTTP version used in the request is not supported by the server. + + /// The server has an internal configuration error: the chosen variant resource is configured to engage in transparent + /// content negotiation itself, and is therefore not a proper end point in the negotiation process. + const VariantAlsoNegotiates: "506" +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/VariantAlsoNegotiates. +// documentation +// > The server has an internal configuration error: the chosen variant resource is configured to engage in transparent +// > content negotiation itself, and is therefore not a proper end point in the negotiation process. + + /// The method could not be performed on the resource because the server is unable to store the representation needed + /// to successfully complete the request. + const InsufficientStorage: "507" +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/InsufficientStorage. +// documentation +// > The method could not be performed on the resource because the server is unable to store the representation needed +// > to successfully complete the request. + + /// The server detected an infinite loop while processing the request. + const LoopDetected: "508" +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/LoopDetected. +// documentation +// > The server detected an infinite loop while processing the request. + + /// Further extensions to the request are required for the server to fulfill it. + const NotExtended: "510" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/NotExtended. +// documentation +// > Further extensions to the request are required for the server to fulfill it. + + /// Indicates that the client needs to authenticate to gain network access. + const NetworkAuthenticationRequired: "511" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/NetworkAuthenticationRequired. +// documentation +// > Indicates that the client needs to authenticate to gain network access. + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Header.pkl b/pkl-pantrysnapshot/org.openapis.v3/Header.pkl new file mode 100755 index 00000000..6dfd32c8 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Header.pkl @@ -0,0 +1,55 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The Header Object follows the structure of the Parameter Object with the + /// following changes: + /// + /// * name MUST NOT be specified, it is given in the corresponding headers map. + /// * in MUST NOT be specified, it is implicitly in header. + /// * All traits that are affected by the location MUST be applicable to a + /// location of header (for example, style). + module org.openapis.v3.Header +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Header.pkl`/ + + extends "BaseParameter.pkl" + + import "Schema.pkl" + import "Reference.pkl" + + /// Determines whether this parameter is mandatory. + required: Boolean? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Header.pkl`/required. +//documentation +//> Determines whether this parameter is mandatory. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Describes how the parameter value will be serialized depending on the type of the parameter value. + /// + /// In this case, it's a header, so it should always be "simple". + style: "simple"? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Header.pkl`/style. +//documentation +//> Describes how the parameter value will be serialized depending on the type of the parameter value. +//> +//> In this case, it's a header, so it should always be "simple". + + /// The schema defining the type used for the parameter. + schema: (*Schema|Reference)? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Header.pkl`/schema. +//documentation +//> The schema defining the type used for the parameter. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Info.pkl b/pkl-pantrysnapshot/org.openapis.v3/Info.pkl new file mode 100755 index 00000000..c3f19441 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Info.pkl @@ -0,0 +1,102 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The object provides metadata about the API. + /// + /// The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation + /// tools for convenience. + module org.openapis.v3.Info +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Info.pkl`/ + + import "Extension.pkl" + import "Contact.pkl" + import "License.pkl" + + /// The title of the API + title: String +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Info.pkl`/title. +//documentation +//> The title of the API +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The version of the OpenAPI document (which is distinct from the OpenAPI Specification version or the API + /// implementation version). + version: String +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Info.pkl`/version. +//documentation +//> The version of the OpenAPI document (which is distinct from the OpenAPI Specification version or the API +//> implementation version). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A short description of the API. + /// + /// CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Info.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Info.pkl`/description. +//documentation +//> A short description of the API. +//> +//> CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A URL to the Terms of Service for the API. + /// + /// MUST be in the format of a URL. + termsOfService: Uri? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Info.pkl`/termsOfService. +//documentation +//> A URL to the Terms of Service for the API. +//> +//> MUST be in the format of a URL. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + + /// The contact information for the exposed API. + contact: Contact? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Info.pkl`/contact. +//documentation +//> The contact information for the exposed API. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Contact.pkl`/ + + /// The license information for the exposed API. + license: License? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Info.pkl`/license. +//documentation +//> The license information for the exposed API. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `License.pkl`/ + + /// Custom properties starting with x- extend OpenAPI with additional information + /// or functionality. + /// + /// This is a child property because Pkl modules cannot express both known names + /// and arbitrary names. + /// + /// + hidden extensions: Mapping? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Info.pkl`/extensions. +// documentation +// > Custom properties starting with x- extend OpenAPI with additional information +// > or functionality. +// > +// > This is a child property because Pkl modules cannot express both known names +// > and arbitrary names. +// > +// > +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Extension.pkl`/Key# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/License.pkl b/pkl-pantrysnapshot/org.openapis.v3/License.pkl new file mode 100755 index 00000000..a49d963b --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/License.pkl @@ -0,0 +1,37 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// License information for the exposed API. + module org.openapis.v3.License +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `License.pkl`/ + + /// The license name used for the API. + name: String +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `License.pkl`/name. +//documentation +//> The license name used for the API. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A URL to the license used for the API. + /// + /// MUST be in the format of a URL. + url: Uri? +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `License.pkl`/url. +//documentation +//> A URL to the license used for the API. +//> +//> MUST be in the format of a URL. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Link.pkl b/pkl-pantrysnapshot/org.openapis.v3/Link.pkl new file mode 100755 index 00000000..a6873ddc --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Link.pkl @@ -0,0 +1,112 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The Link object represents a possible design-time link for a response. + /// + /// The presence of a link does not guarantee the caller's ability to + /// successfully invoke it, rather it provides a known relationship and + /// traversal mechanism between responses and other operations. + /// + /// Unlike dynamic links (i.e. links provided in the response payload), the + /// OAS linking mechanism does not require link information in the runtime + /// response. + /// + /// For computing links, and providing instructions to execute them, a + /// runtime expression is used for accessing values in an operation and using + /// them as parameters while invoking the linked operation. + /// + /// A linked operation MUST be identified using either an operationRef or + /// operationId. In the case of an operationId, it MUST be unique and + /// resolved in the scope of the OAS document. Because of the potential + /// for name clashes, the operationRef syntax is preferred for specifications + /// with external references. + module org.openapis.v3.Link +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Link.pkl`/ + + import "expressions.pkl" + import "Server.pkl" + + /// A description of the link. + /// + /// CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Link.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Link.pkl`/description. +//documentation +//> A description of the link. +//> +//> CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A relative or absolute URI reference to an OAS operation. + /// + /// This field is mutually exclusive of the operationId field, and MUST point to an Operation Object. Relative + /// operationRef values MAY be used to locate an existing Operation Object in the OpenAPI definition. + operationRef: Uri?(!(this != null && operationId != null)) +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Link.pkl`/operationRef. +//documentation +//> A relative or absolute URI reference to an OAS operation. +//> +//> This field is mutually exclusive of the operationId field, and MUST point to an Operation Object. Relative +//> operationRef values MAY be used to locate an existing Operation Object in the OpenAPI definition. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Link.pkl`/operationId. + + /// The name of an existing, resolvable OAS operation, as defined with a unique operationId. + /// + /// This field is mutually exclusive of the operationRef field. + operationId: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Link.pkl`/operationId. +//documentation +//> The name of an existing, resolvable OAS operation, as defined with a unique operationId. +//> +//> This field is mutually exclusive of the operationRef field. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A map representing parameters to pass to an operation as specified with operationId or identified via operationRef. + /// + /// The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and + /// passed to the linked operation. The parameter name can be qualified using the parameter location [{in}.]{name} + /// for operations that use the same parameter name in different locations (e.g. path.id). + parameters: Mapping? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Link.pkl`/parameters. +//documentation +//> A map representing parameters to pass to an operation as specified with operationId or identified via operationRef. +//> +//> The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and +//> passed to the linked operation. The parameter name can be qualified using the parameter location `{in}.`{name} +//> for operations that use the same parameter name in different locations (e.g. path.id). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + /// A literal value or {expression} to use as a request body when calling the target operation. + requestBody: (expressions.Expression|Any)? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Link.pkl`/requestBody. +//documentation +//> A literal value or {expression} to use as a request body when calling the target operation. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + /// A server object to be used by the target operation. + server: Server? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Link.pkl`/server. +//documentation +//> A server object to be used by the target operation. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Server.pkl`/ + diff --git a/pkl-pantrysnapshot/org.openapis.v3/MediaType.pkl b/pkl-pantrysnapshot/org.openapis.v3/MediaType.pkl new file mode 100755 index 00000000..566dd665 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/MediaType.pkl @@ -0,0 +1,97 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Each Media Type Object provides schema and examples for the media type identified by its key. + module org.openapis.v3.MediaType +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/ + + import "Schema.pkl" + import "Encoding.pkl" + import "Reference.pkl" + + /// Common media types that are used with OpenAPI specs. + typealias MediaTypeName = +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/MediaTypeName# +// documentation +// > Common media types that are used with OpenAPI specs. + "application/json" + |"application/xml" + |"application/x-www-form-urlencoded" + |"multipart/form-data" + |"text/plain; charset=utf-8" + |"text/html" + |String +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The schema defining the content of the request, response, or parameter. + schema: (*Schema|Reference)? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/schema. +//documentation +//> The schema defining the content of the request, response, or parameter. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// Example of the parameter's potential value. The example SHOULD match the + /// specified schema and encoding properties if present. The example field is + /// mutually exclusive of the examples field. Furthermore, if referencing a + /// schema that contains an example, the example value SHALL override the + /// example provided by the schema. To represent examples of media types that + /// cannot naturally be represented in JSON or YAML, a string value can contain + /// the example with escaping where necessary. + example: Any?(!(this != null && examples != null)) +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/example. +//documentation +//> Example of the parameter's potential value. The example SHOULD match the +//> specified schema and encoding properties if present. The example field is +//> mutually exclusive of the examples field. Furthermore, if referencing a +//> schema that contains an example, the example value SHALL override the +//> example provided by the schema. To represent examples of media types that +//> cannot naturally be represented in JSON or YAML, a string value can contain +//> the example with escaping where necessary. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/examples. + + /// Examples of the parameter's potential value. Each example SHOULD contain + /// a value in the correct format as specified in the parameter encoding. + /// The examples field is mutually exclusive of the example field. + /// Furthermore, if referencing a schema that contains an example, + /// the examples value SHALL override the example provided by the schema. + examples: Mapping? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/examples. +//documentation +//> Examples of the parameter's potential value. Each example SHOULD contain +//> a value in the correct format as specified in the parameter encoding. +//> The examples field is mutually exclusive of the example field. +//> Furthermore, if referencing a schema that contains an example, +//> the examples value SHALL override the example provided by the schema. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + /// A map between a property name and its encoding information. The key, being + /// the property name, MUST exist in the schema as a property. The encoding + /// object SHALL only apply to requestBody objects when the media type is + /// multipart or application/x-www-form-urlencoded. + encoding: Mapping? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/encoding. +//documentation +//> A map between a property name and its encoding information. The key, being +//> the property name, MUST exist in the schema as a property. The encoding +//> object SHALL only apply to requestBody objects when the media type is +//> multipart or application/x-www-form-urlencoded. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Encoding.pkl`/ + diff --git a/pkl-pantrysnapshot/org.openapis.v3/OAuthFlows.pkl b/pkl-pantrysnapshot/org.openapis.v3/OAuthFlows.pkl new file mode 100755 index 00000000..ba919f8e --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/OAuthFlows.pkl @@ -0,0 +1,109 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Specific OAuth flow types. + module org.openapis.v3.OAuthFlows +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/ + + /// Configuration for the OAuth Implicit flow. + implicit: OAuthFlow(authorizationUrl != null)? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/implicit. +//documentation +//> Configuration for the OAuth Implicit flow. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow#authorizationUrl. + + /// Configuration for the OAuth Resource Owner Password flow. + password: OAuthFlow(tokenUrl != null)? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/password. +//documentation +//> Configuration for the OAuth Resource Owner Password flow. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow#tokenUrl. + + /// Configuration for the OAuth Client Credentials flow. + /// + /// Previously called application in OpenAPI 2.0. + clientCredentials: OAuthFlow(tokenUrl != null)? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/clientCredentials. +//documentation +//> Configuration for the OAuth Client Credentials flow. +//> +//> Previously called application in OpenAPI 2.0. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow#tokenUrl. + + /// Configuration for the OAuth Authorization Code flow. + /// + /// Previously called accessCode in OpenAPI 2.0. + authorizationCode: OAuthFlow(tokenUrl != null && authorizationUrl != null)? +//^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/authorizationCode. +//documentation +//> Configuration for the OAuth Authorization Code flow. +//> +//> Previously called accessCode in OpenAPI 2.0. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow#tokenUrl. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow#authorizationUrl. + + /// Definition of an OAuth flow. + class OAuthFlow { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow# +// documentation +// > Definition of an OAuth flow. + + /// The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. + refreshUrl: Uri? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow#refreshUrl. +// documentation +// > The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + + /// The available scopes for the OAuth2 security scheme. + /// + /// A map between the scope name and a short description for it. The map MAY be empty. + scopes: Mapping +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow#scopes. +// documentation +// > The available scopes for the OAuth2 security scheme. +// > +// > A map between the scope name and a short description for it. The map MAY be empty. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The authorization URL to be used for this flow. + /// + /// This MUST be in the form of a URL. + authorizationUrl: Uri? +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow#authorizationUrl. +// documentation +// > The authorization URL to be used for this flow. +// > +// > This MUST be in the form of a URL. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + + /// The token URL to be used for this flow. + /// + /// This MUST be in the form of a URL. + tokenUrl: Uri? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/OAuthFlow#tokenUrl. +// documentation +// > The token URL to be used for this flow. +// > +// > This MUST be in the form of a URL. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Operation.pkl b/pkl-pantrysnapshot/org.openapis.v3/Operation.pkl new file mode 100755 index 00000000..1cac093f --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Operation.pkl @@ -0,0 +1,231 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Describes a single API operation on a path. + module org.openapis.v3.Operation +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/ + + import "expressions.pkl" + import "ExternalDocs.pkl" + import "Parameter.pkl" + import "Reference.pkl" + import "RequestBody.pkl" + import "Response.pkl" + import "Security.pkl" + import "Server.pkl" + import "PathItem.pkl" + import "HTTPResponse.pkl" + + /// A list of tags for API documentation control. + /// + /// Tags can be used for logical grouping of operations by resources or any other qualifier. + tags: Listing(isDistinct)? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/tags. +//documentation +//> A list of tags for API documentation control. +//> +//> Tags can be used for logical grouping of operations by resources or any other qualifier. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. + + /// A short summary of what the operation does. + summary: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/summary. +//documentation +//> A short summary of what the operation does. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/description. +//documentation +//> A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Additional external documentation for this operation. + externalDocs: ExternalDocs? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/externalDocs. +//documentation +//> Additional external documentation for this operation. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ExternalDocs.pkl`/ + + /// Unique string used to identify the operation. + /// + /// The id MUST be unique among all operations described in the API. The operationId value is case-sensitive. Tools + /// and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow + /// common programming naming conventions. + operationId: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/operationId. +//documentation +//> Unique string used to identify the operation. +//> +//> The id MUST be unique among all operations described in the API. The operationId value is case-sensitive. Tools +//> and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow +//> common programming naming conventions. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A list of parameters that are applicable for this operation. + /// + /// If a parameter is already defined at the Path Item, the new definition will override it but can never remove it. + /// The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and + /// location. The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object's + /// components/parameters. + parameters: Parameters? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/parameters. +//documentation +//> A list of parameters that are applicable for this operation. +//> +//> If a parameter is already defined at the Path Item, the new definition will override it but can never remove it. +//> The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and +//> location. The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object's +//> components/parameters. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/Parameters# + + // follow the uniqueness standard for parameters set forth by the spec + typealias Parameters = Listing<*Parameter|Reference>( +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/Parameters# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + isDistinctBy((it) -> if (it is Parameter) "\(it.name)\(it.`in`)" else it.`$ref`)) +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinctBy(). +// ^^ definition local it_62 +// ^^ reference local it_62 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/ +// ^^ reference local it_62 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/name. +// ^^ reference local it_62 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/in. +// ^^ reference local it_62 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/$ref. + + /// The request body applicable for this operation. + /// + /// The requestBody is only supported in HTTP methods where the HTTP 1.1 specification RFC7231 has explicitly defined + /// semantics for request bodies. In other cases where the HTTP spec is vague, requestBody SHALL be ignored by + /// consumers. + requestBody: (*RequestBody|Reference)? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/requestBody. +//documentation +//> The request body applicable for this operation. +//> +//> The requestBody is only supported in HTTP methods where the HTTP 1.1 specification RFC7231 has explicitly defined +//> semantics for request bodies. In other cases where the HTTP spec is vague, requestBody SHALL be ignored by +//> consumers. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `RequestBody.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// The list of possible responses as they are returned from executing this operation. + /// + /// Any HTTP status code can be used as the property name, but only one property per code, to describe the expected + /// response for that HTTP statuscode. You can use const values of [HTTPResponse] for this, eg. + /// + /// ```pkl + /// [HTTPResponse.OK] { ... } + /// ``` + /// + /// A Reference Object can link to a response that is defined in the OpenAPI + /// Object's components/responses section. To define a range of response codes, this field MAY contain the uppercase + /// wildcard character X. For example, 2XX represents all response codes between [200-299]. Only the following range + /// definitions are allowed: 1XX, 2XX, 3XX, 4XX, and 5XX. If a response is defined using an explicit code, the explicit + /// code definition takes precedence over the range definition for that code. + responses: Mapping? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/responses. +//documentation +//> The list of possible responses as they are returned from executing this operation. +//> +//> Any HTTP status code can be used as the property name, but only one property per code, to describe the expected +//> response for that HTTP statuscode. You can use const values of [`HTTPResponse`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/HTTPResponse.pkl#L18,C1) for this, eg. +//> +//> ```pkl +//> [`HTTPResponse.OK`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/HTTPResponse.pkl#L64,C1) { ... } +//> ``` +//> +//> A Reference Object can link to a response that is defined in the OpenAPI +//> Object's components/responses section. To define a range of response codes, this field MAY contain the uppercase +//> wildcard character X. For example, 2XX represents all response codes between `200-299`. Only the following range +//> definitions are allowed: 1XX, 2XX, 3XX, 4XX, and 5XX. If a response is defined using an explicit code, the explicit +//> code definition takes precedence over the range definition for that code. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/Code# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `HTTPResponse.pkl`/CodeWildcard# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Response.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// A map of possible out-of band callbacks related to the parent operation. + /// + /// The key is a unique identifier for the Callback Object. Each value in the map is a Callback Object that describes a + /// request that may be initiated by the API provider and the expected responses. + callbacks: Mapping|Reference>? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/callbacks. +//documentation +//> A map of possible out-of band callbacks related to the parent operation. +//> +//> The key is a unique identifier for the Callback Object. Each value in the map is a Callback Object that describes a +//> request that may be initiated by the API provider and the expected responses. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// Declares this operation to be deprecated. + /// + /// Consumers SHOULD refrain from usage of the declared operation. Default value is false. + deprecated: Boolean? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/deprecated. +//documentation +//> Declares this operation to be deprecated. +//> +//> Consumers SHOULD refrain from usage of the declared operation. Default value is false. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// A declaration of which security mechanisms can be used for this operation. + /// + /// The list of values includes alternative security requirement objects that can be used. Only one of the security + /// requirement objects need to be satisfied to authorize a request. To make security optional, an empty security + /// requirement ({}) can be included in the array. This definition overrides any declared top-level security. To + /// remove a top-level security declaration, an empty array can be used. + security: Listing? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/security. +//documentation +//> A declaration of which security mechanisms can be used for this operation. +//> +//> The list of values includes alternative security requirement objects that can be used. Only one of the security +//> requirement objects need to be satisfied to authorize a request. To make security optional, an empty security +//> requirement ({}) can be included in the array. This definition overrides any declared top-level security. To +//> remove a top-level security declaration, an empty array can be used. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Security.pkl`/Requirement# + + /// An alternative server array to service this operation. + /// + /// If an alternative server object is specified at the Path Item Object or Root level, it will be overridden by this + /// value. + servers: Listing? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/servers. +//documentation +//> An alternative server array to service this operation. +//> +//> If an alternative server object is specified at the Path Item Object or Root level, it will be overridden by this +//> value. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Server.pkl`/ + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Parameter.pkl b/pkl-pantrysnapshot/org.openapis.v3/Parameter.pkl new file mode 100755 index 00000000..b419865a --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Parameter.pkl @@ -0,0 +1,140 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.openapis.v3.Parameter +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/ + + extends "BaseParameter.pkl" + + import "Schema.pkl" + import "Reference.pkl" + import "MediaType.pkl" + + /// The name of the parameter. + /// + /// Parameter names are case sensitive. + /// + /// * If in is "path", the name field MUST correspond to a template expression occurring within the path field in the + /// Paths Object. See Path Templating for further information. + /// * If in is "header" and the name field is "Accept", "Content-Type" or "Authorization", the parameter definition + /// SHALL be ignored. + /// * For all other cases, the name corresponds to the parameter name used by the in property. + name: String +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/name. +//documentation +//> The name of the parameter. +//> +//> Parameter names are case sensitive. +//> +//> * If in is "path", the name field MUST correspond to a template expression occurring within the path field in the +//> Paths Object. See Path Templating for further information. +//> * If in is "header" and the name field is "Accept", "Content-Type" or "Authorization", the parameter definition +//> SHALL be ignored. +//> * For all other cases, the name corresponds to the parameter name used by the in property. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The location of the parameter. + `in`: "query"|"header"|"path"|"cookie" +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/in. +//documentation +//> The location of the parameter. + + /// Determines whether the parameter value SHOULD allow reserved characters, as defined by RFC3986 :/?#[]@!$&'()*+,;= + /// to be included without percent-encoding. + /// + /// This property only applies to parameters with an in value of query. The default value is false. + allowReserved: Boolean(implies(`in` == "query"))? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/allowReserved. +//documentation +//> Determines whether the parameter value SHOULD allow reserved characters, as defined by RFC3986 :/?#[]@!$&'()*+,;= +//> to be included without percent-encoding. +//> +//> This property only applies to parameters with an in value of query. The default value is false. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/in. + + /// Determines whether this parameter is mandatory. + /// + /// If the parameter location is "path", this property is REQUIRED and its value MUST be true. Otherwise, the property + /// MAY be included and its default value is false. + required: Boolean?((`in` == "path").implies(this == true)) +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/required. +//documentation +//> Determines whether this parameter is mandatory. +//> +//> If the parameter location is "path", this property is REQUIRED and its value MUST be true. Otherwise, the property +//> MAY be included and its default value is false. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/in. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). + + /// Allowed values for a parameter's style. + typealias Style = "matrix"|"label"|"form"|"simple"|"spaceDelimited"|"pipeDelimited"|"deepObject" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/Style# +// documentation +// > Allowed values for a parameter's style. + + /// Describes how the parameter value will be serialized depending on the type of the parameter value. + /// + /// Default values (based on value of in): for query - form; for path - simple; for header - simple; for cookie - form. + style: Style( +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/style. +//documentation +//> Describes how the parameter value will be serialized depending on the type of the parameter value. +//> +//> Default values (based on value of in): for query - form; for path - simple; for header - simple; for cookie - form. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/Style# + if (List("matrix", "label").contains(this)) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#contains(). + `in` == "path" +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/in. + else if (this == "form") + List("query", "cookie").contains(`in`) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#contains(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/in. + else if (this == "simple") + List("header", "path").contains(`in`) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#contains(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/in. + else `in` == "query" +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/in. + )? + + /// The schema defining the type used for the parameter. + schema: (*Schema|Reference)? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/schema. +//documentation +//> The schema defining the type used for the parameter. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// A map containing the representations for the parameter. + /// + /// The key is the media type and the value describes it. The map MUST only contain one entry. + content: Mapping(length == 1)? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/content. +//documentation +//> A map containing the representations for the parameter. +//> +//> The key is the media type and the value describes it. The map MUST only contain one entry. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/MediaTypeName# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#length. + diff --git a/pkl-pantrysnapshot/org.openapis.v3/PathItem.pkl b/pkl-pantrysnapshot/org.openapis.v3/PathItem.pkl new file mode 100755 index 00000000..307e3fa1 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/PathItem.pkl @@ -0,0 +1,142 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Describes the operations available on a single path. + /// + /// A Path Item MAY be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer but + /// they will not know which operations and parameters are available. + module org.openapis.v3.PathItem +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/ + + import "Operation.pkl" + import "Server.pkl" + import "Parameter.pkl" + import "Reference.pkl" + + /// Allows for an external definition of this path item. + /// + /// The referenced structure MUST be in the format of a Path Item Object. In case a Path Item Object field appears + /// both in the defined object and the referenced object, the behavior is undefined. + `$ref`: Uri? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/$ref. +//documentation +//> Allows for an external definition of this path item. +//> +//> The referenced structure MUST be in the format of a Path Item Object. In case a Path Item Object field appears +//> both in the defined object and the referenced object, the behavior is undefined. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + + /// An optional, string summary, intended to apply to all operations in this path. + summary: String? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/summary. +//documentation +//> An optional, string summary, intended to apply to all operations in this path. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// An optional, string description, intended to apply to all operations in this path. + /// + /// CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/description. +//documentation +//> An optional, string description, intended to apply to all operations in this path. +//> +//> CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A definition of a GET operation on this path. + get: Operation? +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/get. +//documentation +//> A definition of a GET operation on this path. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/ + + /// A definition of a PUT operation on this path. + put: Operation? +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/put. +//documentation +//> A definition of a PUT operation on this path. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/ + + /// A definition of a POST operation on this path. + post: Operation? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/post. +//documentation +//> A definition of a POST operation on this path. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/ + + /// A definition of a DELETE operation on this path. + `delete`: Operation? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/delete. +//documentation +//> A definition of a DELETE operation on this path. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/ + + /// A definition of an OPTIONS operation on this path. + options: Operation? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/options. +//documentation +//> A definition of an OPTIONS operation on this path. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/ + + /// A definition of a HEAD operation on this path. + head: Operation? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/head. +//documentation +//> A definition of a HEAD operation on this path. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/ + + /// A definition of a PATCH operation on this path. + patch: Operation? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/patch. +//documentation +//> A definition of a PATCH operation on this path. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/ + + /// A definition of a TRACE operation on this path. + `trace`: Operation? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/trace. +//documentation +//> A definition of a TRACE operation on this path. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Operation.pkl`/ + + /// An alternative server array to service all operations in this path. + servers: Listing? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/servers. +//documentation +//> An alternative server array to service all operations in this path. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Server.pkl`/ + + /// A list of parameters that are applicable for all the operations described under this path. + /// + /// These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include + /// duplicated parameters. A unique parameter is defined by a combination of a name and location. The list can use the + /// Reference Object to link to parameters that are defined at the OpenAPI Object's components/parameters. + parameters: Listing<*Parameter|Reference>? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `PathItem.pkl`/parameters. +//documentation +//> A list of parameters that are applicable for all the operations described under this path. +//> +//> These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include +//> duplicated parameters. A unique parameter is defined by a combination of a name and location. The list can use the +//> Reference Object to link to parameters that are defined at the OpenAPI Object's components/parameters. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Parameter.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + diff --git a/pkl-pantrysnapshot/org.openapis.v3/PklProject b/pkl-pantrysnapshot/org.openapis.v3/PklProject new file mode 100755 index 00000000..61b3e9f9 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/PklProject @@ -0,0 +1,24 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Modules for describing [OpenAPI](https://www.openapis.org/) v3.x + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 PklProject/package. + version = "2.2.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Reference.pkl b/pkl-pantrysnapshot/org.openapis.v3/Reference.pkl new file mode 100755 index 00000000..8d6b5dd9 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Reference.pkl @@ -0,0 +1,34 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A reference to other components in the specification, internally and externally. + /// + /// The Reference Object is defined by [JSON Reference](https://datatracker.ietf.org/doc/html/draft-pbryan-zyp-json-ref-03) + /// and follows the same structure, behavior and rules. + /// + /// For this specification, reference resolution is accomplished as defined by the JSON Reference specification + /// and not by the JSON Schema specification. + /// + /// https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#reference-object + module org.openapis.v3.Reference +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// The reference URI + `$ref`: Uri +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/$ref. +//documentation +//> The reference URI +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/RequestBody.pkl b/pkl-pantrysnapshot/org.openapis.v3/RequestBody.pkl new file mode 100755 index 00000000..584996dc --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/RequestBody.pkl @@ -0,0 +1,60 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.openapis.v3.RequestBody +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `RequestBody.pkl`/ + + import "MediaType.pkl" + + /// A brief description of the request body. + /// + /// This could contain examples of use. CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `RequestBody.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `RequestBody.pkl`/description. +//documentation +//> A brief description of the request body. +//> +//> This could contain examples of use. CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The content of the request body. + /// + /// The key is a media type or media type range and the value describes it. For requests that match multiple + /// keys, only the most specific key is applicable. e.g. text/plain overrides text/* + content: Mapping? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `RequestBody.pkl`/content. +//documentation +//> The content of the request body. +//> +//> The key is a media type or media type range and the value describes it. For requests that match multiple +//> keys, only the most specific key is applicable. e.g. text/plain overrides text/* +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/MediaTypeName# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/ + + /// Determines if the request body is required in the request. + /// + /// Defaults to false. + required: Boolean? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `RequestBody.pkl`/required. +//documentation +//> Determines if the request body is required in the request. +//> +//> Defaults to false. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Response.pkl b/pkl-pantrysnapshot/org.openapis.v3/Response.pkl new file mode 100755 index 00000000..06add2e1 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Response.pkl @@ -0,0 +1,84 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Describes a single response from an API Operation, including design-time, static links to operations based on the + /// response. + module org.openapis.v3.Response +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Response.pkl`/ + + import "Header.pkl" + import "Reference.pkl" + import "MediaType.pkl" + import "Link.pkl" + + /// A short description of the response. + /// + /// CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Response.pkl`/language. + description: String +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Response.pkl`/description. +//documentation +//> A short description of the response. +//> +//> CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Maps a header name to its definition. + /// + /// RFC7230 states header names are case insensitive. If a response header is defined with the name "Content-Type", + /// it SHALL be ignored. + headers: Mapping? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Response.pkl`/headers. +//documentation +//> Maps a header name to its definition. +//> +//> RFC7230 states header names are case insensitive. If a response header is defined with the name "Content-Type", +//> it SHALL be ignored. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Header.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + /// A map containing descriptions of potential response payloads. + /// + /// The key is a media type or media type range and the value describes it. For responses that match multiple keys, + /// only the most specific key is applicable. e.g. text/plain overrides text/* + content: Mapping? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Response.pkl`/content. +//documentation +//> A map containing descriptions of potential response payloads. +//> +//> The key is a media type or media type range and the value describes it. For responses that match multiple keys, +//> only the most specific key is applicable. e.g. text/plain overrides text/* +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `MediaType.pkl`/ + + /// A map of operations links that can be followed from the response. + /// + /// The key of the map is a short name for the link, following the naming constraints of the names for Component Objects. + links: Mapping? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Response.pkl`/links. +//documentation +//> A map of operations links that can be followed from the response. +//> +//> The key of the map is a short name for the link, following the naming constraints of the names for Component Objects. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Link.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Schema.pkl b/pkl-pantrysnapshot/org.openapis.v3/Schema.pkl new file mode 100755 index 00000000..436d9527 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Schema.pkl @@ -0,0 +1,831 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// The Schema object as defined by the OpenAPI v3.0 Specification. + /// + /// The [Schema] object allows the definition of input and output data types. + /// These types can be objects, but also primitives and arrays. + /// This object is an extended subset of + /// [JSON Schema Specification Wright Draft 00](http://json-schema.org/specification-links.html#draft-5) + /// (a.k.a. JSON Schema Draft 5). + /// + /// For more information about the properties, see + /// [JSON Schema Core](https://tools.ietf.org/html/draft-wright-json-schema-00) and + /// [JSON Schema Validation](https://tools.ietf.org/html/draft-wright-json-schema-validation-00). + /// + /// **NOTE**: OpenAPI v3.0's schema object is incompatible with OpenAPI v3.1's schema object. + /// For example, [nullable] is valid on v3.0, but is invalid in v3.1. + /// + /// + open module org.openapis.v3.Schema +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + + import "Extension.pkl" + import "Reference.pkl" + import "Schema.pkl" + + /// The basic type of the value represented by this schema. + /// + /// If this property is not defined, the value may be of any type. + type: ("string"|"number"|"integer"|"boolean"|"object"|"array")? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. +//documentation +//> The basic type of the value represented by this schema. +//> +//> If this property is not defined, the value may be of any type. + + /// An additional descriptor for the value represented by this schema. + /// + /// OAS uses several known formats to define in fine detail the data type being used. + /// + /// However, to support documentation needs, the [format] property is an open `string`-valued property, and can have any value. + /// Formats such as `"email"`, `"uuid"`, and so on, *may* be used even though undefined by this specification. + /// Types that are not accompanied by a `format` property follow the type definition in the JSON Schema. Tools that do + /// not recognize a specific [format] *may* default to the [type] alone, as if the [format] is not specified. + /// + /// The formats defined by the OAS are: + /// + /// Common Name | [type] | [format] | Comments + /// ----------- | ------ | -------- | -------- + /// integer | `integer` | `int32` | signed 32 bits + /// long | `integer` | `int64` | signed 64 bits + /// float | `number` | `float` | | + /// double | `number` | `double` | | + /// string | `string` | | | + /// byte | `string` | `byte` | base64 encoded characters + /// binary | `string` | `binary` | any sequence of octets + /// boolean | `boolean` | | | + /// date | `string` | `date` | As defined by `full-date` - [RFC3339](http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) + /// dateTime | `string` | `date-time` | As defined by `date-time` - [RFC3339](http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) + /// password | `string` | `password` | A hint to UIs to obscure input. + /// + /// + format: ("int32"|"int64"|"float"|"double"|"byte"|"binary"|"date"|"date-time"|"password"|String)? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/format. +//documentation +//> An additional descriptor for the value represented by this schema. +//> +//> OAS uses several known formats to define in fine detail the data type being used. +//> +//> However, to support documentation needs, the [`format`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L69,C1) property is an open `string`-valued property, and can have any value. +//> Formats such as `"email"`, `"uuid"`, and so on, *may* be used even though undefined by this specification. +//> Types that are not accompanied by a `format` property follow the type definition in the JSON Schema. Tools that do +//> not recognize a specific [`format`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L69,C1) *may* default to the [`type`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L41,C1) alone, as if the [`format`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L69,C1) is not specified. +//> +//> The formats defined by the OAS are: +//> +//> Common Name | [`type`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L41,C1) | [`format`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L69,C1) | Comments +//> ----------- | ------ | -------- | -------- +//> integer | `integer` | `int32` | signed 32 bits +//> long | `integer` | `int64` | signed 64 bits +//> float | `number` | `float` | | +//> double | `number` | `double` | | +//> string | `string` | | | +//> byte | `string` | `byte` | base64 encoded characters +//> binary | `string` | `binary` | any sequence of octets +//> boolean | `boolean` | | | +//> date | `string` | `date` | As defined by `full-date` - [RFC3339](http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) +//> dateTime | `string` | `date-time` | As defined by `date-time` - [RFC3339](http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) +//> password | `string` | `password` | A hint to UIs to obscure input. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A short descriptor of this schema. + /// + /// + title: String? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/title. +//documentation +//> A short descriptor of this schema. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A long descriptor of this schema. Maybe written in Markdown. + /// + /// + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/description. +//documentation +//> A long descriptor of this schema. Maybe written in Markdown. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Specifies a default value. + /// + /// This value is not used to fill in missing values during the validation process. + /// Non-validation tools such as documentation generators or form + /// generators may use this value to give hints to users about how to use + /// a value. However, [default] is typically used to express that if a + /// value is missing, then the value is semantically the same as if the + /// value was present with the default value. The value of [default] + /// should validate against the schema in which it resides, but that isn't + /// required. + /// + /// + default: Any? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/default. +//documentation +//> Specifies a default value. +//> +//> This value is not used to fill in missing values during the validation process. +//> Non-validation tools such as documentation generators or form +//> generators may use this value to give hints to users about how to use +//> a value. However, [`default`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L93,C1) is typically used to express that if a +//> value is missing, then the value is semantically the same as if the +//> value was present with the default value. The value of [`default`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L93,C1) +//> should validate against the schema in which it resides, but that isn't +//> required. +//> +//> +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + /// Restricts the value specified by this schema to a fixed set of values. + /// + /// It must be an array with at least one element, where each element is unique. + /// + /// You can use enum even without a type, to accept values of different types. + /// + /// Elements in the array might be of any type, including [null]. + /// + enum: Listing(!isEmpty && isDistinct)? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/enum. +//documentation +//> Restricts the value specified by this schema to a fixed set of values. +//> +//> It must be an array with at least one element, where each element is unique. +//> +//> You can use enum even without a type, to accept values of different types. +//> +//> Elements in the array might be of any type, including `null`. +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. + + // === Numeric type validators === + + /// Restricts to a number that is a multiple of this value. + /// + /// It may be set to any positive number. + /// + /// + multipleOf: Number(type is ("number"|"integer") && isPositive)? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/multipleOf. +//documentation +//> Restricts to a number that is a multiple of this value. +//> +//> It may be set to any positive number. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#isPositive. + + /// Represent a number that is greater or equal to this value. + /// + /// + minimum: Number(type is ("number"|"integer"))? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/minimum. +//documentation +//> Represent a number that is greater or equal to this value. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent a number that is greater than this value. + /// + /// + exclusiveMinimum: Number(type is ("number"|"integer"))? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/exclusiveMinimum. +//documentation +//> Represent a number that is greater than this value. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent a number that is less than or equal to this value. + /// + /// + maximum: Number(type is ("number"|"integer"))? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/maximum. +//documentation +//> Represent a number that is less than or equal to this value. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent a number that is less than this value. + /// + /// + exclusiveMaximum: Number(type is ("number"|"integer"))? +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/exclusiveMaximum. +//documentation +//> Represent a number that is less than this value. +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + // === String validators === + + /// Represent a string that adheres to a regex pattern. + /// + /// The regular expression must conform to [ECMA 262](https://262.ecma-international.org/5.1/#sec-7.8.5). + /// + /// + pattern: String(isRegex && type == "string")? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/pattern. +//documentation +//> Represent a string that adheres to a regex pattern. +//> +//> The regular expression must conform to [ECMA 262](https://262.ecma-international.org/5.1/#sec-7.8.5). +//> +//> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isRegex. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent a string that has a minimum length. + /// + /// + minLength: UInt(type == "string")? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/minLength. +//documentation +//> Represent a string that has a minimum length. +//> +//> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent a string that has a maximum length. + /// + /// + maxLength: UInt(type == "string")? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/maxLength. +//documentation +//> Represent a string that has a maximum length. +//> +//> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + // == Array validators == + + /// Represent that each item in an array must conform to the specified schema. + /// + /// If the type is array, [items] must be specified. + items: (Schema|Reference)(type == "array")? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/items. +//documentation +//> Represent that each item in an array must conform to the specified schema. +//> +//> If the type is array, [`items`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L158,C1) must be specified. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent an array that has a minumum length. + /// + /// + minItems: UInt(type == "array")? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/minItems. +//documentation +//> Represent an array that has a minumum length. +//> +//> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent an array that has a maximum length. + /// + /// + maxItems: UInt(type == "array")? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/maxItems. +//documentation +//> Represent an array that has a maximum length. +//> +//> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent an array where each item is unique. + /// + /// + uniqueItems: Boolean? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/uniqueItems. +//documentation +//> Represent an array where each item is unique. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + // == Objects == + + /// Represent an object that must have at minimum a certain number of properties. + /// + /// + minProperties: UInt(type == "object")? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/minProperties. +//documentation +//> Represent an object that must have at minimum a certain number of properties. +//> +//> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent an object that must have at maximum a certain number of properties. + maxProperties: UInt(type == "object")? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/maxProperties. +//documentation +//> Represent an object that must have at maximum a certain number of properties. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent an object that have properties that conform to a + /// certain schema. + /// + /// + properties: Mapping(type == "object")? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/properties. +//documentation +//> Represent an object that have properties that conform to a +//> certain schema. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/PropertySchema# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent an object that has additional properties. + /// + /// The value of [additionalProperties] is a schema that + /// will be used to validate any properties in the instance that are not + /// matched by [properties]. Setting the + /// [additionalProperties] schema to [false] means no additional + /// properties will be allowed. + /// + /// + additionalProperties: (*PropertySchema|Boolean|Reference)(type == "object")? +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/additionalProperties. +//documentation +//> Represent an object that has additional properties. +//> +//> The value of [`additionalProperties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L200,C1) is a schema that +//> will be used to validate any properties in the instance that are not +//> matched by [`properties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L189,C1). Setting the +//> [`additionalProperties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L200,C1) schema to `false` means no additional +//> properties will be allowed. +//> +//> +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/PropertySchema# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. + + /// Represent an object that has certain properties defined on it. + /// + /// By default, no properties are required. + /// + /// + required: Listing(type == "object", isDistinct)? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/required. +//documentation +//> Represent an object that has certain properties defined on it. +//> +//> By default, no properties are required. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/type. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. + + // == Composition == + + /// Represent a value that must match against **exactly** one of the subschemas. + /// + /// + oneOf: Listing(length > 0)? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/oneOf. +//documentation +//> Represent a value that must match against **exactly** one of the subschemas. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#length. + + /// Represent a value that must match **at least one** of the subschemas. + /// + /// + anyOf: Listing(length > 0)? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/anyOf. +//documentation +//> Represent a value that must match **at least one** of the subschemas. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#length. + + /// Represent a value that must match **all** of the subschemas. + /// + /// + allOf: Listing(length > 0)? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/allOf. +//documentation +//> Represent a value that must match **all** of the subschemas. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#length. + + /// Represent a value that must not match the given schema. + /// + /// + not: (Schema|Reference)? +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/not. +//documentation +//> Represent a value that must not match the given schema. +//> +//> +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Reference.pkl`/ + + // == OpenAPI v3.0 specific fields == + + /// Represent that the value may optionally be [null]. + /// + /// Default value is [false]. + /// + /// + nullable: Boolean? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/nullable. +//documentation +//> Represent that the value may optionally be `null`. +//> +//> Default value is `false`. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Helps inform of alternative schemas. + /// + /// When request bodies or response payloads may be one of a number of different + /// schemas, a discriminator object can be used to aid in serialization, + /// deserialization, and validation. The discriminator is a specific object in + /// a schema which is used to inform the consumer of the specification of an + /// alternative schema based on the value associated with it. + /// + /// When using the discriminator, inline schemas will not be considered. + /// + /// + discriminator: Discriminator? +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/discriminator. +//documentation +//> Helps inform of alternative schemas. +//> +//> When request bodies or response payloads may be one of a number of different +//> schemas, a discriminator object can be used to aid in serialization, +//> deserialization, and validation. The discriminator is a specific object in +//> a schema which is used to inform the consumer of the specification of an +//> alternative schema based on the value associated with it. +//> +//> When using the discriminator, inline schemas will not be considered. +//> +//> +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/Discriminator# + + /// Declares the property as "read only". + /// + /// Relevant only for Schema [properties] definitions. This means that + /// it *may* be sent as part of a response but *should not* be sent as part + /// of the request. If the property is marked as [readOnly] and is in the + /// [required] list, [required] only effects the response. A property + /// *may not* be marked as both [readOnly] and [writeOnly]. + /// + /// Default value is [false]. + /// + /// + readOnly: Boolean? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/readOnly. +//documentation +//> Declares the property as "read only". +//> +//> Relevant only for Schema [`properties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L189,C1) definitions. This means that +//> it *may* be sent as part of a response but *should not* be sent as part +//> of the request. If the property is marked as [`readOnly`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L264,C1) and is in the +//> [`required`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L207,C1) list, [`required`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L207,C1) only effects the response. A property +//> *may not* be marked as both [`readOnly`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L264,C1) and [`writeOnly`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L277,C1). +//> +//> Default value is `false`. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Declares the property as "write only". + /// + /// This is relevant only for Schema [properties] definitions. Therefore, it + /// it *may* be sent as part of a response but *should not* be sent as part + /// If the property is marked as [writeOnly] being [true] and is in the [required] list, + /// the [required] will take effect on the request only. A property *may not* be marked + /// as both [readOnly] and [writeOnly] being [true]. + /// + /// Default value is [false]. + /// + /// + writeOnly: Boolean(implies(readOnly != true))? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/writeOnly. +//documentation +//> Declares the property as "write only". +//> +//> This is relevant only for Schema [`properties`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L189,C1) definitions. Therefore, it +//> it *may* be sent as part of a response but *should not* be sent as part +//> If the property is marked as [`writeOnly`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L277,C1) being `true` and is in the [`required`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L207,C1) list, +//> the [`required`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L207,C1) will take effect on the request only. A property *may not* be marked +//> as both [`readOnly`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L264,C1) and [`writeOnly`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L277,C1) being `true`. +//> +//> Default value is `false`. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/readOnly. + + /// Additional external documentation for this schema. + externalDocs: ExternalDocumentation? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/externalDocs. +//documentation +//> Additional external documentation for this schema. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ExternalDocumentation# + + /// Indicates that this property is deprecated. + /// + /// Default value is [false]. + /// + /// + deprecated: Boolean? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/deprecated. +//documentation +//> Indicates that this property is deprecated. +//> +//> Default value is `false`. +//> +//> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// A free-form property to include an example of an instance for this schema. + /// + /// To represent examples that cannot be naturally represented in JSON or YAML, a string + /// value can be used to contain the example with escaping where necessary. + example: Any? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/example. +//documentation +//> A free-form property to include an example of an instance for this schema. +//> +//> To represent examples that cannot be naturally represented in JSON or YAML, a string +//> value can be used to contain the example with escaping where necessary. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + /// Custom properties starting with x- extend OpenAPI with additional information + /// or functionality. + /// + /// This is a child property because Pkl modules cannot express both known names + /// and arbitrary names. + /// + /// + hidden extensions: Mapping? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/extensions. +// documentation +// > Custom properties starting with x- extend OpenAPI with additional information +// > or functionality. +// > +// > This is a child property because Pkl modules cannot express both known names +// > and arbitrary names. +// > +// > +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Extension.pkl`/Key# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + /// Helps inform of alternative schemas. + /// + /// When request bodies or response payloads may be one of a number of different + /// schemas, a discriminator object can be used to aid in serialization, + /// deserialization, and validation. The discriminator is a specific object in + /// a schema which is used to inform the consumer of the specification of an + /// alternative schema based on the value associated with it. + /// + /// When using the discriminator, inline schemas will not be considered. + /// + /// + class Discriminator { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/Discriminator# +// documentation +// > Helps inform of alternative schemas. +// > +// > When request bodies or response payloads may be one of a number of different +// > schemas, a discriminator object can be used to aid in serialization, +// > deserialization, and validation. The discriminator is a specific object in +// > a schema which is used to inform the consumer of the specification of an +// > alternative schema based on the value associated with it. +// > +// > When using the discriminator, inline schemas will not be considered. +// > +// > + /// The name of the property in the payload that holds the discriminator value. + propertyName: String +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/Discriminator#propertyName. +// documentation +// > The name of the property in the payload that holds the discriminator value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A mapping from payload values to schema names or references. + mapping: Mapping? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/Discriminator#mapping. +// documentation +// > A mapping from payload values to schema names or references. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// Reference to an external resource for extended documentation. + /// + /// + class ExternalDocumentation { +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ExternalDocumentation# +// documentation +// > Reference to an external resource for extended documentation. +// > +// > + /// A short description of the target documentation. + /// + /// [CommonMark syntax](https://spec.commonmark.org) *may* be used for rich text representation. + description: String? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ExternalDocumentation#description. +// documentation +// > A short description of the target documentation. +// > +// > [CommonMark syntax](https://spec.commonmark.org) *may* be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The URL for the target documentation. + /// + /// Value *must* be in the format of a URL. + uri: Uri +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ExternalDocumentation#uri. +// documentation +// > The URL for the target documentation. +// > +// > Value *must* be in the format of a URL. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + } + + /// A metadata object that allows for more fine-tuned XML model definitions. + /// + /// When using arrays, XML element names are not inferred (for singular/plural + /// forms) and the [name] property **should** be used to add that information. + /// + /// + class Xml { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/Xml# +// documentation +// > A metadata object that allows for more fine-tuned XML model definitions. +// > +// > When using arrays, XML element names are not inferred (for singular/plural +// > forms) and the [`name`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L350,C3) property **should** be used to add that information. +// > +// > + /// Replaces the name of the element/attribute used for the described schema property. + /// + /// When defined within [items], it affects the name of the individual XML elements within the list. + /// When defined alongside [type] being `array` (outside the [items]), it affects the wrapping element + /// and only if [wrapped] is [true]. If [wrapped] is [false], it is ignored. + name: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/Xml#name. +// documentation +// > Replaces the name of the element/attribute used for the described schema property. +// > +// > When defined within [`items`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L158,C1), it affects the name of the individual XML elements within the list. +// > When defined alongside [`type`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L41,C1) being `array` (outside the [`items`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L158,C1)), it affects the wrapping element +// > and only if [`wrapped`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L369,C3) is `true`. If [`wrapped`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L369,C3) is `false`, it is ignored. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The URI of the namespace definition. Value MUST be in the form of an absolute URI. + namespace: Uri? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/Xml#namespace. +// documentation +// > The URI of the namespace definition. Value MUST be in the form of an absolute URI. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# + + /// The prefix used for the [name]. + prefix: String? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/Xml#prefix. +// documentation +// > The prefix used for the [`name`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L350,C3). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Declares whether the property definition translates to an attribute instead of an element. + /// + /// Default value is [false]. + attribute: Boolean? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/Xml#attribute. +// documentation +// > Declares whether the property definition translates to an attribute instead of an element. +// > +// > Default value is `false`. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Signifies whether the array is wrapped (for example, ``) + /// or unwrapped (``). + /// + /// *May* be used only for an array definition. Default value is [false]. + /// + /// The definition takes effect only when defined alongside [type] being `array` (outside the items). + wrapped: Boolean? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/Xml#wrapped. +// documentation +// > Signifies whether the array is wrapped (for example, ``) +// > or unwrapped (``). +// > +// > *May* be used only for an array definition. Default value is `false`. +// > +// > The definition takes effect only when defined alongside [`type`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L41,C1) being `array` (outside the items). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + /// Property schemas are [Schema]s that optionally include XML metadata. + class PropertySchema extends Schema { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/PropertySchema# +// documentation +// > Property schemas are [`Schema`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/org.openapis.v3/Schema.pkl#L32,C1)s that optionally include XML metadata. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/ + /// Adds additional metadata to describe the XML representation of this property. + /// + /// This *may* be used only on properties schemas. It has no effect on root schemas. + xml: Xml? +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/PropertySchema#xml. +// documentation +// > Adds additional metadata to describe the XML representation of this property. +// > +// > This *may* be used only on properties schemas. It has no effect on root schemas. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/Xml# + } + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/output. + // It's pretty common to have OpenAPI written in YAML. Therefore, we support the YAML format too. + // noinspection TypeMismatch + local const format: "json"|"yaml"|"pcf" = read?("prop:pkl.outputFormat") ?? "json" +// ^^^^^^ definition local format_383 + + local const renderers: Mapping = new { +// ^^^^^^^^^ definition local renderers_385 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer# + ["json"] = new JsonRenderer {} +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer# + ["yaml"] = new YamlRenderer {} +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/YamlRenderer# + ["pcf"] = new PcfRenderer {} +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer# + } + + renderer = (renderers[format]) { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/renderer. +// ^^^^^^^^^ reference local renderers_385 +// ^^^^^^ reference local format_383 + converters = Extension.converters +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Schema.pkl`/converters. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Extension.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Extension.pkl`/converters. + } + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Security.pkl b/pkl-pantrysnapshot/org.openapis.v3/Security.pkl new file mode 100755 index 00000000..d3ce63e6 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Security.pkl @@ -0,0 +1,49 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Various security data types. + module org.openapis.v3.Security +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Security.pkl`/ + + /// Lists the required security schemes to execute this operation. + /// + /// The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the + /// Components Object. + /// + /// Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a + /// request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers + /// are required to convey security information. + /// + /// When a list of Security Requirement Objects is defined on the OpenAPI Object or Operation Object, only one of the + /// Security Requirement Objects in the list needs to be satisfied to authorize the request. + typealias Requirement = Mapping> +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Security.pkl`/Requirement# +// documentation +// > Lists the required security schemes to execute this operation. +// > +// > The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the +// > Components Object. +// > +// > Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a +// > request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers +// > are required to convey security information. +// > +// > When a list of Security Requirement Objects is defined on the OpenAPI Object or Operation Object, only one of the +// > Security Requirement Objects in the list needs to be satisfied to authorize the request. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/SecurityScheme.pkl b/pkl-pantrysnapshot/org.openapis.v3/SecurityScheme.pkl new file mode 100755 index 00000000..6e6bacdc --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/SecurityScheme.pkl @@ -0,0 +1,129 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Contact information for the exposed API. + module org.openapis.v3.SecurityScheme +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/ + + import "Extension.pkl" + import "OAuthFlows.pkl" + + typealias SecuritySchemeType = "apiKey"|"http"|"oauth2"|"openIdConnect" +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/SecuritySchemeType# + typealias SecuritySchemeIn = "query"|"header"|"cookie" +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/SecuritySchemeIn# + + /// The type of the security scheme. + type: SecuritySchemeType +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/type. +//documentation +//> The type of the security scheme. +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/SecuritySchemeType# + + /// A short description for security scheme. + /// + /// CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/description. +//documentation +//> A short description for security scheme. +//> +//> CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The name of the header, query or cookie parameter to be used. + name: String?((this != null).implies(type == "apiKey")) +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/name. +//documentation +//> The name of the header, query or cookie parameter to be used. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/type. + + /// The location of the API key. + `in`: SecuritySchemeIn?((this != null).implies(type == "apiKey")) +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/in. +//documentation +//> The location of the API key. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/SecuritySchemeIn# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/type. + + scheme: String((this == "bearer").implies(bearerFormat != null)) +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/scheme. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/bearerFormat. + + /// A hint to the client to identify how the bearer token is formatted. + /// + /// Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation + /// purposes. + bearerFormat: String(type == "http")? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/bearerFormat. +//documentation +//> A hint to the client to identify how the bearer token is formatted. +//> +//> Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation +//> purposes. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/type. + + /// An object containing configuration information for the flow types supported. + flows: OAuthFlows?((type == "oauth2").implies(this != null)) +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/flows. +//documentation +//> An object containing configuration information for the flow types supported. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `OAuthFlows.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). + + /// OpenId Connect URL to discover OAuth2 configuration values. + /// + /// This MUST be in the form of a URL. + openIdConnectUrl: Uri?((type == "openIdConnect").implies(this != null)) +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/openIdConnectUrl. +//documentation +//> OpenId Connect URL to discover OAuth2 configuration values. +//> +//> This MUST be in the form of a URL. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/type. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean#implies(). + + /// Custom properties starting with x- extend OpenAPI with additional information + /// or functionality. + /// + /// This is a child property because Pkl modules cannot express both known names + /// and arbitrary names. + /// + /// + hidden extensions: Mapping? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `SecurityScheme.pkl`/extensions. +// documentation +// > Custom properties starting with x- extend OpenAPI with additional information +// > or functionality. +// > +// > This is a child property because Pkl modules cannot express both known names +// > and arbitrary names. +// > +// > +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Extension.pkl`/Key# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Server.pkl b/pkl-pantrysnapshot/org.openapis.v3/Server.pkl new file mode 100755 index 00000000..18afd7a3 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Server.pkl @@ -0,0 +1,63 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// An object representing a Server. + module org.openapis.v3.Server +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Server.pkl`/ + + import "ServerVariable.pkl" + + /// A URL to the target host. + /// + /// This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the + /// location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named + /// in {brackets}. + url: String +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Server.pkl`/url. +//documentation +//> A URL to the target host. +//> +//> This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the +//> location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named +//> in {brackets}. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// An optional string describing the host designated by the URL. + /// + /// CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Server.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Server.pkl`/description. +//documentation +//> An optional string describing the host designated by the URL. +//> +//> CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A map between a variable name and its value. + /// + /// The value is used for substitution in the server's URL template. + variables: Mapping? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Server.pkl`/variables. +//documentation +//> A map between a variable name and its value. +//> +//> The value is used for substitution in the server's URL template. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ServerVariable.pkl`/ + diff --git a/pkl-pantrysnapshot/org.openapis.v3/ServerVariable.pkl b/pkl-pantrysnapshot/org.openapis.v3/ServerVariable.pkl new file mode 100755 index 00000000..71067368 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/ServerVariable.pkl @@ -0,0 +1,65 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// An object representing a Server Variable for server URL template + /// substitution. + module org.openapis.v3.ServerVariable +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ServerVariable.pkl`/ + + /// An enumeration of string values to be used if the substitution options are from a limited set. + /// + /// The array SHOULD NOT be empty. + enum: Listing(!isEmpty, isDistinct)? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ServerVariable.pkl`/enum. +//documentation +//> An enumeration of string values to be used if the substitution options are from a limited set. +//> +//> The array SHOULD NOT be empty. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. + + /// The default value to use for substitution, which SHALL be sent if an alternate value is not supplied. + /// + /// Note this behavior is different than the Schema Object's treatment of default values, because in those cases + /// parameter values are optional. If the enum is defined, the value SHOULD exist in the enum's values. + default: String(enum == null || enum.toList().contains(this)) +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ServerVariable.pkl`/default. +//documentation +//> The default value to use for substitution, which SHALL be sent if an alternate value is not supplied. +//> +//> Note this behavior is different than the Schema Object's treatment of default values, because in those cases +//> parameter values are optional. If the enum is defined, the value SHOULD exist in the enum's values. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ServerVariable.pkl`/enum. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ServerVariable.pkl`/enum. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#contains(). + + /// An optional description for the server variable. + /// + /// CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ServerVariable.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ServerVariable.pkl`/description. +//documentation +//> An optional description for the server variable. +//> +//> CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + diff --git a/pkl-pantrysnapshot/org.openapis.v3/Tag.pkl b/pkl-pantrysnapshot/org.openapis.v3/Tag.pkl new file mode 100755 index 00000000..19279e74 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/Tag.pkl @@ -0,0 +1,51 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Adds metadata to a single tag that is used by the Operation Object. + /// + /// It is not mandatory to have a Tag Object per tag defined in the Operation Object instances. + module org.openapis.v3.Tag +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Tag.pkl`/ + + import "ExternalDocs.pkl" + + /// The name of the tag. + name: String +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Tag.pkl`/name. +//documentation +//> The name of the tag. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// A short description for the tag. + /// + /// CommonMark syntax MAY be used for rich text representation. + @SourceCode { language = "Markdown" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/SourceCode# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Tag.pkl`/language. + description: String? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Tag.pkl`/description. +//documentation +//> A short description for the tag. +//> +//> CommonMark syntax MAY be used for rich text representation. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Additional external documentation for this tag. + externalDocs: ExternalDocs? +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Tag.pkl`/externalDocs. +//documentation +//> Additional external documentation for this tag. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `ExternalDocs.pkl`/ + diff --git a/pkl-pantrysnapshot/org.openapis.v3/examples/extension-example.pkl b/pkl-pantrysnapshot/org.openapis.v3/examples/extension-example.pkl new file mode 100755 index 00000000..41359045 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/examples/extension-example.pkl @@ -0,0 +1,57 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + amends "../Document.pkl" + + info { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/info. + title = "Extension Example" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/title. + version = "1.0.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/version. + extensions { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/extensions. + ["x-key"] = "info" + } + } + + components { +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/components. + schemas { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/schemas. + ["Schema"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/type. + extensions { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/extensions. + ["x-key"] = "schema" + } + } + } + securitySchemes { +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/securitySchemes. + ["basicAuth"] { + type = "http" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/type. + scheme = "basic" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/scheme. + extensions { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/extension-example.pkl`/extensions. + ["x-key"] = "basicAuth" + } + } + } + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3/examples/link-example.pkl b/pkl-pantrysnapshot/org.openapis.v3/examples/link-example.pkl new file mode 100755 index 00000000..30514228 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/examples/link-example.pkl @@ -0,0 +1,175 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + amends "../Document.pkl" + + info { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/info. + title = "Link Example" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/title. + version = "1.0.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/version. + } + + paths { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/paths. + ["/2.0/users/{username}"] { + get { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/get. + operationId = "getUserByName" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/operationId. + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/parameters. + new { + name = "username" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/name. + `in` = "path" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/in. + required = true +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/required. + schema { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/schema. + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/type. + } + } + } + responses { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/responses. + ["200"] { + description = "The User" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/description. + content { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/content. + ["application/json"] { + schema = new Reference { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/schema. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# + `$ref` = "#/components/schemas/user" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/$ref. + } + } + } + links { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/links. + ["userRepositories"] = new Reference { +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# + `$ref` = "#/components/links/UserRepositories" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/$ref. + } + } + } + } + } + } + ["/2.0/repositories/{username}"] { + get { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/get. + operationId = "getRepositoriesByOwner" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/operationId. + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/parameters. + new { + name = "username" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/name. + `in` = "path" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/in. + required = true +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/required. + schema { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/schema. + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/type. + } + } + } + responses { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/responses. + ["200"] { + description = "repositories owned by the supplied user" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/description. + content { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/content. + ["application/json"] { + schema { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/schema. + type = "array" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/type. + items = new Reference { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/items. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# + `$ref` = "#/components/schemas/repository" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/$ref. + } + } + } + } + links { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/links. + ["userRepository"] = new Reference { +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# + `$ref` = "#/components/links/UserRepository" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/$ref. + } + } + } + } + } + } + } + + components { +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/components. + links { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/links. + ["UserRepositories"] { + operationId = "getRepositoriesByOwner" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/operationId. + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/parameters. + ["username"] = "$response.body#/username" + } + } + ["UserRepository"] { + operationId = "getRepository" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/operationId. + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/parameters. + ["username"] = "$response.body#/username" + ["slug"] = "$response.body#/slug" + } + } + ["RepositoryPullRequests"] { + operationId = "getPullRequestsByRepository" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/operationId. + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/parameters. + ["username"] = "$response.body#/owner/username" + ["slug"] = "$response.body#/slug" + } + } + ["PullRequestMerge"] { + operationId = "mergePullRequest" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/operationId. + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/link-example.pkl`/parameters. + ["username"] = "$response.body#/author/username" + ["slug"] = "$response.body#/repository/slug" + ["pid"] = "$response.body#/id" + } + } + } + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3/examples/petstore.pkl b/pkl-pantrysnapshot/org.openapis.v3/examples/petstore.pkl new file mode 100755 index 00000000..e1f6c0e9 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/examples/petstore.pkl @@ -0,0 +1,289 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Adaptation of + amends "../Document.pkl" + + info { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/info. + title = "Swagger Petstore" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/title. + version = "1.0.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/version. + license { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/license. + name = "MIT" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/name. + } + } + + servers { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/servers. + new { url = "http://petstore.swagger.io/v1" } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/url. + } + + paths { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/paths. + ["/pets"] { + get { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/get. + summary = "List all pets" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/summary. + operationId = "listPets" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/operationId. + tags { "pets" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/tags. + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/parameters. + new { + name = "limit" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/name. + `in` = "query" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/in. + description = "How many items to return at one time (max 100)" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/description. + required = false +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/required. + schema { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/schema. + type = "integer" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/type. + maximum = 100 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/maximum. + format = "int32" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/format. + } + } + } + responses { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/responses. + ["200"] { + description = "A paged array of pets" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/description. + headers { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/headers. + ["x-next"] { + description = "A link to the next page of responses" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/description. + schema { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/schema. + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/type. + } + } + } + content { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/content. + ["application/json"] { + schema = new Reference { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/schema. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# + `$ref` = "#/components/schemas/Pets" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/$ref. + } + } + } + } + default { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/default. + description = "unexpected error" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/description. + content { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/content. + ["application/json"] { + schema = new Reference { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/schema. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# + `$ref` = "#/components/schemas/Error" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/$ref. + } + } + } + } + } + } + post { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/post. + summary = "Create a pet" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/summary. + operationId = "createPets" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/operationId. + tags { "pets" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/tags. + requestBody { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/requestBody. + content { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/content. + ["application/json"] { + schema = new Reference { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/schema. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# + `$ref` = "#/components/schemas/Pet" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/$ref. + } + } + } + required = true +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/required. + } + responses { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/responses. + ["201"] { + description = "Null resposne" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/description. + } + ["default"] { + description = "unexpected error" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/description. + content { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/content. + ["application/json"] { + schema = new Reference { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/schema. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# + `$ref` = "#/components/schemas/Error" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/$ref. + } + } + } + } + } + } + } + ["/pets/{petId}"] { + get { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/get. + summary = "Info for a specific pet" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/summary. + operationId = "showPetById" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/operationId. + tags { "pets" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/tags. + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/parameters. + new { + name = "petId" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/name. + `in` = "path" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/in. + required = true +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/required. + description = "The id of the pet to retrieve" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/description. + schema { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/schema. + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/type. + } + } + } + responses { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/responses. + ["200"] { + description = "Expected response to a valid request" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/description. + content { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/content. + ["application/json"] { + schema = new Reference { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/schema. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# + `$ref` = "#/components/schemas/Pet" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/$ref. + } + } + } + } + ["default"] { + description = "unexpected error" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/description. + content { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/content. + ["application/json"] { + schema = new Reference { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/schema. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# + `$ref` = "#/components/schemas/Error" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/$ref. + } + } + } + } + } + } + } + } + + components { +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/components. + schemas { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/schemas. + ["Pet"] { + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/type. + required { "id"; "name" } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/required. + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/properties. + ["id"] { + type = "integer" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/type. + format = "int64" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/format. + } + ["name"] { type = "string" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/type. + ["tag"] { type = "string" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/type. + } + } + ["Pets"] { + type = "array" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/type. + maxItems = 100 +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/maxItems. + items = new Reference { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/items. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `Document.pkl`/Reference# + `$ref` = "#/components/schemas/Pet" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/$ref. + } + } + ["Error"] { + type = "object" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/type. + required { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/required. + "code" + "message" + } + properties { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/properties. + ["code"] { + type = "integer" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/type. + format = "int32" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/format. + } + ["message"] { + type = "string" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `examples/petstore.pkl`/type. + } + } + } + } + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3/expressions.pkl b/pkl-pantrysnapshot/org.openapis.v3/expressions.pkl new file mode 100755 index 00000000..e0c3b726 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/expressions.pkl @@ -0,0 +1,169 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.openapis.v3.expressions +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/ + + import "expressions.pkl" + + /// A string representing an OpenAPI [Runtime Expression](https://spec.openapis.org/oas/v3.0.3#runtime-expressions). + typealias Expression = +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# +// documentation +// > A string representing an OpenAPI [Runtime Expression](https://spec.openapis.org/oas/v3.0.3#runtime-expressions). + "$url" + |"$method" + |"$statusCode" + |HeaderReferenceExpression +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/HeaderReferenceExpression# + |QueryOrPathReferenceExpression +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/QueryOrPathReferenceExpression# + |BodyReferenceExpression +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/BodyReferenceExpression# + + /// A string representing a reference to a header of a request or response. + typealias HeaderReferenceExpression = +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/HeaderReferenceExpression# +// documentation +// > A string representing a reference to a header of a request or response. + String(matches(Regex(#"\$(?:request|response)\.header\.[0-9A-z!#$%&'+\-.^_`|~]+"#))) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + + /// A string representing a reference to a query param, or a path segment. + typealias QueryOrPathReferenceExpression = +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/QueryOrPathReferenceExpression# +// documentation +// > A string representing a reference to a query param, or a path segment. + String(expressions.isQueryOrPathReference) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/isQueryOrPathReference. + + hidden isQueryOrPathReference = (it) -> +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/isQueryOrPathReference. +// ^^ definition local it_37 + let (suffix = it.replaceFirst(Regex(#"\$(?:request|response)\.(?:query|path)\."#), "")) +// ^^^^^^ definition local suffix_38 +// ^^ reference local it_37 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + if (suffix == it) false +// ^^^^^^ reference local suffix_38 +// ^^ reference local it_37 + else expressions.isJsonName(it) +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/isJsonName(). +// ^^ reference local it_37 + + /// A string representing a reference to a segment in the body of a request or response. + typealias BodyReferenceExpression = +// ^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/BodyReferenceExpression# +// documentation +// > A string representing a reference to a segment in the body of a request or response. + "$request.body" + |"$response.body" + |String(expressions.isBodyReference) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/isBodyReference. + + /// Tells if this string is `body-reference` of a Runtime Expression. + /// + /// + hidden isBodyReference = (it: String) -> +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/isBodyReference. +// documentation +// > Tells if this string is `body-reference` of a Runtime Expression. +// > +// > +// ^^ definition local it_51 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (suffix = it.replaceFirst(Regex(#"\$(?:request|response)\.body#"#), "")) +// ^^^^^^ definition local suffix_52 +// ^^ reference local it_51 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + if (suffix == it) false +// ^^^^^^ reference local suffix_52 +// ^^ reference local it_51 + else expressions.isJsonPointer(suffix) +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/isJsonPointer(). +// ^^^^^^ reference local suffix_52 + + // json-pointer = *( "/" reference-token ) + function isJsonPointer(it: String) = +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/isJsonPointer(). +// ^^ definition local it_57 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + it.startsWith("/") +// ^^ reference local it_57 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + && !it.endsWith("/") +// ^^ reference local it_57 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#endsWith(). + && it.split("/").every(isReferenceToken) +// ^^ reference local it_57 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^^^^^^^^^^^^^^^ reference local isReferenceToken_62 + + /// Tells if the input string is a `reference-token` in a Runtime Expression. + /// + /// + local isReferenceToken = (it) -> +// ^^^^^^^^^^^^^^^^ definition local isReferenceToken_62 +// documentation +// > Tells if the input string is a `reference-token` in a Runtime Expression. +// > +// > +// ^^ definition local it_65 + // language=regexp + it.matches(Regex(#""" +// ^^ reference local it_65 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + (?x) # extended mode + (?: + ~0 + |~1 + |[\x00-\x2E] + |[\x30-\x7D] + |[\x7f-\x{10ffff}] + )* + """#)) + + /// Tells if the input string is valid JSON name. + /// + /// JSON string spec: + function isJsonName(it) = +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/isJsonName(). +// documentation +// > Tells if the input string is valid JSON name. +// > +// > JSON string spec: +// ^^ definition local it_81 + // language=regexp + it.matches(Regex(#""" +// ^^ reference local it_81 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + (?x) # extended mode + (?: + [\x20-\x21\x23-\x5B\x5D-\x{10ffff}] # unescaped char (%x20-21 / %x23-5B / %x5D-10FFFF) + |\\["\\/bfnrt] # escaped char (e.g. `\n`) + |\\u[0-9a-f]{4} # code point literal + )* + """#)) + diff --git a/pkl-pantrysnapshot/org.openapis.v3/tests/Document.pkl b/pkl-pantrysnapshot/org.openapis.v3/tests/Document.pkl new file mode 100755 index 00000000..ea67f053 --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/tests/Document.pkl @@ -0,0 +1,43 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.openapis.v3.tests.Document +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `tests/Document.pkl`/ + + amends "pkl:test" + + local allExamples = import*("../examples/*.pkl") +// ^^^^^^^^^^^ definition local allExamples_20 + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `tests/Document.pkl`/examples. + for (example in allExamples.keys) { +// ^^^^^^^ definition local example_23 +// ^^^^^^^^^^^ reference local allExamples_20 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#keys. + [example.drop("../examples/".length).dropLast(4)] { +// ^^^^^^^ reference local example_23 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#dropLast(). + allExamples[example].output.text +// ^^^^^^^^^^^ reference local allExamples_20 +// ^^^^^^^ reference local example_23 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + } + diff --git a/pkl-pantrysnapshot/org.openapis.v3/tests/expressions.pkl b/pkl-pantrysnapshot/org.openapis.v3/tests/expressions.pkl new file mode 100755 index 00000000..9a22104e --- /dev/null +++ b/pkl-pantrysnapshot/org.openapis.v3/tests/expressions.pkl @@ -0,0 +1,46 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module org.openapis.v3.tests.expressions +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `tests/expressions.pkl`/ + + amends "pkl:test" + + import "../expressions.pkl" + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `tests/expressions.pkl`/facts. + ["Expression"] { + "$method" is expressions.Expression +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# + "$request.header.accept" is expressions.Expression +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# + "$request.path.id" is expressions.Expression +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# + "$request.body#/user/uuid" is expressions.Expression +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# + "$url" is expressions.Expression +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# + "$response.body#/status" is expressions.Expression +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# + "$response.header.Server" is expressions.Expression +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# + !("bar" is expressions.Expression) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# + !("$request.header.über" is expressions.Expression) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3 2.2.0 `expressions.pkl`/Expression# + } + } + diff --git a/pkl-pantrysnapshot/pkl.csv/PklProject b/pkl-pantrysnapshot/pkl.csv/PklProject new file mode 100755 index 00000000..07c255cc --- /dev/null +++ b/pkl-pantrysnapshot/pkl.csv/PklProject @@ -0,0 +1,24 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A [RFC4180](https://www.ietf.org/rfc/rfc4180.txt) compliant CSV [Renderer] and [Parser]. + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 PklProject/package. + version = "1.1.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/pkl.csv/csv.pkl b/pkl-pantrysnapshot/pkl.csv/csv.pkl new file mode 100755 index 00000000..d248826b --- /dev/null +++ b/pkl-pantrysnapshot/pkl.csv/csv.pkl @@ -0,0 +1,814 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A renderer for Comma Separated Values (CSV) files, following [RFC 4180](https://www.ietf.org/rfc/rfc4180.txt). + /// + /// Basic usage: + /// ``` + /// import "package:#/csv.pkl" + /// + /// output { + /// renderer = new csv.Renderer {} + /// } + /// ``` + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/minPklVersion. + module pkl.csv.csv +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/ + + import "pkl:reflect" + + typealias Value = Null|Number|String|Boolean +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Value# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + typealias ListLike = List|Listing|Dynamic(toMap().isEmpty) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/ListLike# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#isEmpty. + + const local listLikeDescription = "`List`s, `Listing`s, or `Dynamic`s with only elements" +// ^^^^^^^^^^^^^^^^^^^ definition local listLikeDescription_35 + + const local function mapOf(thing): Map = +// ^^^^^ definition local mapOf_37 +// ^^^^^ definition local thing_37 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# + if (thing is Map) thing else thing?.toMap() ?? Map() +// ^^^^^ reference local thing_37 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^ reference local thing_37 +// ^^^^^ reference local thing_37 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + + /// Renders values as CSV. + class Renderer extends ValueRenderer { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer# +// documentation +// > Renders values as CSV. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer# + /// Value converters to apply before values are rendered. + /// + /// For further information see [PcfRenderer.converters]. + converters: Mapping Any> +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#converters. +// documentation +// > Value converters to apply before values are rendered. +// > +// > For further information see [`PcfRenderer.converters`](pkl-lsp://stdlib/base.pkl#L308,C3). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + function renderValue(value: Any) = +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderValue(). +// documentation +// > Renders [`value`](pkl-lsp://stdlib/base.pkl#L323,C33). +// ^^^^^ definition local value_47 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + if (value is Null|Number|String|Boolean) +// ^^^^^ reference local value_47 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + [Null] = "" +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# + [String] = +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (value.contains(charactersToWrap)) +// ^^^^^ reference local value_47 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). +// ^^^^^^^^^^^^^^^^ reference local charactersToWrap_111 + #""\#(value.replaceAll("\"", "\"\""))""# +// ^^^^^ reference local value_47 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + else + value as String +// ^^^^^ reference local value_47 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + }.getOrNull(value.getClass()) ?? "\(value)" +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^ reference local value_47 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^ reference local value_47 + else + throw("The CSV renderer only supports primitive values in `renderValue`.") + + function renderDocument(value: Any) = +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderDocument(). +// documentation +// > Renders [`value`](pkl-lsp://stdlib/base.pkl#L320,C36) as a complete document. +// > +// > Some renderers impose restrictions on which types of values can be rendered as document. +// > +// > A typical implementation of this method renders a document header/footer +// > and otherwise delegates to [`renderValue()`](pkl-lsp://stdlib/base.pkl#L323,C3). +// ^^^^^ definition local value_60 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + let (table = +// ^^^^^ definition local table_61 + if (value is ListLike?) +// ^^^^^ reference local value_60 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/ListLike# + (value as ListLike? ?? List()).toList() +// ^^^^^ reference local value_60 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/ListLike# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). + else + throw("Only \(listLikeDescription) values can be rendered as CSV. Instead, found a \(value.getClass()).\n\nValue:\n\(value)") +// ^^^^^^^^^^^^^^^^^^^ reference local listLikeDescription_35 +// ^^^^^ reference local value_60 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^ reference local value_60 + ) + let (violations = table.filter((it) -> !(if (table.firstOrNull is Value) it is Value else it is Typed|Dynamic|Mapping|Map))) +// ^^^^^^^^^^ definition local violations_67 +// ^^^^^ reference local table_61 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filter(). +// ^^ definition local it_67 +// ^^^^^ reference local table_61 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#firstOrNull. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Value# +// ^^ reference local it_67 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Value# +// ^^ reference local it_67 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# + let (headerKeys = +// ^^^^^^^^^^ definition local headerKeys_68 + if (unification == "pad") +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#unification. + table.fold(Set(), (acc: Set, row) -> acc + row.toMap().keys) +// ^^^^^ reference local table_61 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). +// ^^^ definition local acc_70 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local row_70 +// ^^^ reference local acc_70 +// ^^^ reference local row_70 + else + mapOf(table.firstOrNull).keys +// ^^^^^ reference local mapOf_37 +// ^^^^^ reference local table_61 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#firstOrNull. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#keys. + ) + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + when (!violations.isEmpty) { +// ^^^^^^^^^^ reference local violations_67 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + throw("The CSV renderer only supports rows consisting of primitive values, or of type `Typed|Dynamic|Mapping`.\nValue: \(violations.first)") +// ^^^^^^^^^^ reference local violations_67 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. + } + when (includeHeader) { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#includeHeader. + headerKeys.map((it) -> renderValue(it)).join(",") +// ^^^^^^^^^^ reference local headerKeys_68 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#map(). +// ^^ definition local it_79 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderValue(). +// ^^ reference local it_79 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#join(). + } + for (row in table) { +// ^^^ definition local row_81 +// ^^^^^ reference local table_61 + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + when (unification == "error" && mapOf(row).keys != headerKeys) { +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#unification. +// ^^^^^ reference local mapOf_37 +// ^^^ reference local row_81 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#keys. +// ^^^^^^^^^^ reference local headerKeys_68 + throw("Invalid input: CSV can only render rows with all the same properties. Expecting keys: \(headerKeys.join(",")). Received: \(row).") +// ^^^^^^^^^^ reference local headerKeys_68 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#join(). +// ^^^ reference local row_81 + } + when (includeHeader) { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#includeHeader. + for (column in headerKeys) { +// ^^^^^^ definition local column_87 +// ^^^^^^^^^^ reference local headerKeys_68 + renderValue(mapOf(row).getOrNull(column)) +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderValue(). +// ^^^^^ reference local mapOf_37 +// ^^^ reference local row_81 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#getOrNull(). +// ^^^^^^ reference local column_87 + } + } else { + for (column in if (row is ListLike) row.toList() else row.toMap().values) { +// ^^^^^^ definition local column_91 +// ^^^ reference local row_81 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/ListLike# +// ^^^ reference local row_81 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^ reference local row_81 + renderValue(column) +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderValue(). +// ^^^^^^ reference local column_91 + } + } + }.join(",") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + } + "" + }.join(lineBreak) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#lineBreak. + + /// The line break to use. + /// + /// [RFC 4180](https://www.ietf.org/rfc/rfc4180.txt) states that line breaks are carriage-return-line-feed, but also: + /// > As per section 4.1.1. of RFC 2046, this media type uses CRLF to denote line breaks. + /// > However, implementors should be aware that some implementations may use other values. + /// + /// This property can be used to define which encoding to use. + /// + /// (Default: `"\r\n"`) + lineBreak: String = "\r\n" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#lineBreak. +// documentation +// > The line break to use. +// > +// > [RFC 4180](https://www.ietf.org/rfc/rfc4180.txt) states that line breaks are carriage-return-line-feed, but also: +// > > As per section 4.1.1. of RFC 2046, this media type uses CRLF to denote line breaks. +// > > However, implementors should be aware that some implementations may use other values. +// > +// > This property can be used to define which encoding to use. +// > +// > (Default: `"\r\n"`) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + local charactersToWrap = Regex("[\",]|\(lineBreak)") +// ^^^^^^^^^^^^^^^^ definition local charactersToWrap_111 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#lineBreak. + + /// How to handle polymorphic rows. + /// + /// When rendering a table of `Listing`, which includes elements of type `DerivedX` and `DerivedY` (where both + /// `extends Base`), how should this table be rendered? There are three options: + /// - `"error"` throws an error when any row has property names that are not in the header. + /// - `"drop"` only renders properties with names in the header and ignores any other properties. + /// - `"pad"` gathers property names from the entire table and inserts (pads) empty values when properties are missing. + /// + /// (Default: `"error"`) + unification: * "error"|"drop"|"pad" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#unification. +// documentation +// > How to handle polymorphic rows. +// > +// > When rendering a table of `Listing`, which includes elements of type `DerivedX` and `DerivedY` (where both +// > `extends Base`), how should this table be rendered? There are three options: +// > - `"error"` throws an error when any row has property names that are not in the header. +// > - `"drop"` only renders properties with names in the header and ignores any other properties. +// > - `"pad"` gathers property names from the entire table and inserts (pads) empty values when properties are missing. +// > +// > (Default: `"error"`) + + /// Tells whether to include a (first) line with the names of the columns. + includeHeader: Boolean = true +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#includeHeader. +// documentation +// > Tells whether to include a (first) line with the names of the columns. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + class Parser { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser# + /// The expected type of the rows to parse. + rowClass: Class? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#rowClass. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# + + /// The [String] to parse. + input: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#input. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Tells whether the first row contains names of columns. + includeHeader: Boolean = false +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#includeHeader. +// documentation +// > Tells whether the first row contains names of columns. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The line break to use. + /// + /// [RFC 4180](https://www.ietf.org/rfc/rfc4180.txt) states that line breaks are carriage-return-line-feed, but also: + /// > As per section 4.1.1. of RFC 2046, this media type uses CRLF to denote line breaks. + /// > However, implementors should be aware that some implementations may use other values. + /// + /// This property can be used to define which encoding to use. + /// + /// (Default: `"\r\n"`) + lineBreak: String = "\r\n" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#lineBreak. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + converters: Mapping unknown> = new { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#converters. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + [Int] = (it) -> it.toInt() +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_150 +// ^^ reference local it_150 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + [Float] = (it) -> it.toFloat() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# +// ^^ definition local it_151 +// ^^ reference local it_151 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toFloat(). + [Number] = (it) -> it.toFloat() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^ definition local it_152 +// ^^ reference local it_152 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toFloat(). + [Boolean] = (it) -> it.toBoolean() +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^ definition local it_153 +// ^^ reference local it_153 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toBoolean(). + } + + function parse(source: Resource|String): List(rowClass == null)|List(rowClass != null) = +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#parse(). +// ^^^^^^ definition local source_156 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#rowClass. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#rowClass. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#rowClass. + (this) { input = if (source is String) source else source.text }.parsed +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#input. +// ^^^^^^ reference local source_156 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference local source_156 +// ^^^^^^ reference local source_156 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource#text. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#parsed. + + /// The result of parsing [input] as CSV. + /// + /// This is a "final" property, because it is derived from the input properties [input], [includeHeader] and [rowClass]. + parsed: (* List(rowClass == null)|List(rowClass != null))(this == _parsed) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#parsed. +// documentation +// > The result of parsing [`input`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.csv/csv.pkl#L133,C3) as CSV. +// > +// > This is a "final" property, because it is derived from the input properties [`input`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.csv/csv.pkl#L133,C3), [`includeHeader`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.csv/csv.pkl#L136,C3) and [`rowClass`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.csv/csv.pkl#L130,C3). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#rowClass. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#rowClass. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#rowClass. +// ^^^^^^^ reference local _parsed_179 + _parsed +// ^^^^^^^ reference local _parsed_179 + + local function convert(type: reflect.Type|Class|TypeAlias): (String) -> unknown = +// ^^^^^^^ definition local convert_165 +// ^^^^ definition local type_165 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + new Mapping unknown)?> { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + [reflect.DeclaredType] = convert((type as reflect.DeclaredType).referent.reflectee) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# +// ^^^^^^^ reference local convert_165 +// ^^^^ reference local type_165 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. + [Class] = converters.getOrNull(type) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#converters. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^ reference local type_165 + [TypeAlias] = convert(reflect.TypeAlias(type as TypeAlias).referent) +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# +// ^^^^^^^ reference local convert_165 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias(). +// ^^^^ reference local type_165 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias#referent. + // Support for (type aliases that are) union types is rather ad hoc; pick the first class for which there exists a converter. + // TODO: Improve this. + [reflect.UnionType] = (type as reflect.UnionType).members.fold(null, (acc, ty) -> acc ?? convert(ty)) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType# +// ^^^^ reference local type_165 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType#members. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^ definition local acc_172 +// ^^ definition local ty_172 +// ^^^ reference local acc_172 +// ^^^^^^^ reference local convert_165 +// ^^ reference local ty_172 + }.getOrNull(type.getClass()) ?? (it) -> it +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^ reference local type_165 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^ definition local it_173 +// ^^ reference local it_173 + + local function allProps(clazz: reflect.Class): Map = +// ^^^^^^^^ definition local allProps_175 +// ^^^^^ definition local clazz_175 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# + (clazz.superclass.ifNonNull((zuper) -> allProps(zuper as reflect.Class)) ?? Map()) + +// ^^^^^ reference local clazz_175 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#superclass. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^^^^ definition local zuper_176 +// ^^^^^^^^ reference local allProps_175 +// ^^^^^ reference local zuper_176 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + clazz.properties.filter((_, p) -> !p.modifiers.contains("hidden")) +// ^^^^^ reference local clazz_175 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#properties. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^ definition local p_177 +// ^ reference local p_177 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#modifiers. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). + + local _parsed = +// ^^^^^^^ definition local _parsed_179 + let (self = this) +// ^^^^ definition local self_180 + let (stringyResult = new StringyTableParser { +// ^^^^^^^^^^^^^ definition local stringyResult_181 +// ^^^^^^^^^^^^^^^^^^ reference local StringyTableParser_205 + rowClass = self.rowClass +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#rowClass. +// ^^^^ reference local self_180 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#rowClass. + input = self.input +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#input. +// ^^^^ reference local self_180 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#input. + lineBreak = self.lineBreak +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#lineBreak. +// ^^^^ reference local self_180 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#lineBreak. + }.parseResult.rows.toList()) +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#parseResult. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#rows. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + let (properties: Map? = rowClass.ifNonNull((clazz) -> allProps(reflect.Class(clazz as Class)))) +// ^^^^^^^^^^ definition local properties_186 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#rowClass. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^^^^ definition local clazz_186 +// ^^^^^^^^ reference local allProps_175 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^^^^^ reference local clazz_186 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# + let (header: List? = (if (includeHeader) stringyResult[0] else properties?.keys)?.toList() as List?) +// ^^^^^^ definition local header_187 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#includeHeader. +// ^^^^^^^^^^^^^ reference local stringyResult_181 +// ^^^^^^^^^^ reference local properties_186 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#keys. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (header == null) stringyResult.map((rawRow) -> rawRow.toDynamic()) else +// ^^^^^^ reference local header_187 +// ^^^^^^^^^^^^^ reference local stringyResult_181 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^^^ definition local rawRow_188 +// ^^^^^^ reference local rawRow_188 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toDynamic(). + stringyResult.toList().drop(if (includeHeader) 1 else 0).map((rawRow) -> +// ^^^^^^^^^^^^^ reference local stringyResult_181 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#includeHeader. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^^^ definition local rawRow_189 + let (row = +// ^^^ definition local row_190 + header +// ^^^^^^ reference local header_187 + .zip(rawRow.toList()) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#zip(). +// ^^^^^^ reference local rawRow_189 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toList(). + .toMap((entry) -> entry.first, (entry) -> entry.second) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toMap(). +// ^^^^^ definition local entry_193 +// ^^^^^ reference local entry_193 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^^^^^ definition local entry_193 +// ^^^^^ reference local entry_193 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + ) + if (properties == null) row.toDynamic() else +// ^^^^^^^^^^ reference local properties_186 +// ^^^ reference local row_190 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toDynamic(). + let (spuriousKeys = row.keys.filter((key) -> !properties.containsKey(key))) +// ^^^^^^^^^^^^ definition local spuriousKeys_196 +// ^^^ reference local row_190 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#keys. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#filter(). +// ^^^ definition local key_196 +// ^^^^^^^^^^ reference local properties_186 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#containsKey(). +// ^^^ reference local key_196 + let (_ = if (spuriousKeys.isEmpty) "ok" else throw("Unrecognized keys found in row: \(spuriousKeys.join(", "))")) +// ^^^^^^^^^^^^ reference local spuriousKeys_196 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#isEmpty. +// ^^^^^^^^^^^^ reference local spuriousKeys_196 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#join(). + properties +// ^^^^^^^^^^ reference local properties_186 + .filter((name, _) -> row.containsKey(name)) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^ definition local name_199 +// ^^^ reference local row_190 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#containsKey(). +// ^^^^ reference local name_199 + .mapValues((name, property) -> row[name].ifNonNull((value) -> convert(property.type).apply(value as String))) +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#mapValues(). +// ^^^^ definition local name_200 +// ^^^^^^^^ definition local property_200 +// ^^^ reference local row_190 +// ^^^^ reference local name_200 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^^^^ definition local value_200 +// ^^^^^^^ reference local convert_165 +// ^^^^^^^^ reference local property_200 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^ reference local value_200 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + .toTyped(rowClass!!) +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toTyped(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#rowClass. + ) + } + + local class StringyTableParser { +// ^^^^^^^^^^^^^^^^^^ definition local StringyTableParser_205 + rowClass: Class? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#rowClass. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# + input: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#input. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + position: Int = 0 +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#position. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + currentRow: Listing +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#currentRow. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + rows: Listing> +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#rows. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + lineBreak: String +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#lineBreak. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + local length: Int = input.length - position +// ^^^^^^ definition local length_215 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#input. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#position. + + parseResult: StringyTableParser = if (length <= 0) this else +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#parseResult. +// ^^^^^^^^^^^^^^^^^^ reference local StringyTableParser_205 +// ^^^^^^ reference local length_215 + let (isEscapedField = input.getOrNull(position) == "\"") +// ^^^^^^^^^^^^^^ definition local isEscapedField_218 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#input. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#getOrNull(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#position. + + let (idxValueStart = if (isEscapedField) position + 1 else position) +// ^^^^^^^^^^^^^ definition local idxValueStart_220 +// ^^^^^^^^^^^^^^ reference local isEscapedField_218 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#position. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#position. + let (idxValueEnd = +// ^^^^^^^^^^^ definition local idxValueEnd_221 + List( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + input.length, +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#input. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + if (isEscapedField) +// ^^^^^^^^^^^^^^ reference local isEscapedField_218 + findValueEndIndex(idxValueStart) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#findValueEndIndex(). +// ^^^^^^^^^^^^^ reference local idxValueStart_220 + else + position + (input.drop(position).indexOfOrNull(Regex(",|\(lineBreak)")) ?? length) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#position. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#input. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#position. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#indexOfOrNull(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#lineBreak. +// ^^^^^^ reference local length_215 + ).min +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#min. + ) + let (idxFieldEnd = idxValueEnd + if (isEscapedField) 1 else 0) +// ^^^^^^^^^^^ definition local idxFieldEnd_230 +// ^^^^^^^^^^^ reference local idxValueEnd_221 +// ^^^^^^^^^^^^^^ reference local isEscapedField_218 + let (delimiter = input.getOrNull(idxFieldEnd)) +// ^^^^^^^^^ definition local delimiter_231 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#input. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#getOrNull(). +// ^^^^^^^^^^^ reference local idxFieldEnd_230 + + // Ugly corner-case for CSV, if the input ends with a `,`, there is still a `null` value "after" that, but no `,` or lineBreak to signal as much. + let (nullEnd = delimiter == "," && idxFieldEnd == input.length - 1) +// ^^^^^^^ definition local nullEnd_234 +// ^^^^^^^^^ reference local delimiter_231 +// ^^^^^^^^^^^ reference local idxFieldEnd_230 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#input. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + + let (value = input.substring(idxValueStart, idxValueEnd)) +// ^^^^^ definition local value_236 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#input. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^^^^^^^^^^^^ reference local idxValueStart_220 +// ^^^^^^^^^^^ reference local idxValueEnd_221 + let (newRow = (currentRow) { +// ^^^^^^ definition local newRow_237 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#currentRow. + if (value.isEmpty) null else if (isEscapedField) value.replaceAll("\"\"", "\"") else value +// ^^^^^ reference local value_236 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. +// ^^^^^^^^^^^^^^ reference local isEscapedField_218 +// ^^^^^ reference local value_236 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). +// ^^^^^ reference local value_236 + when (nullEnd) { +// ^^^^^^^ reference local nullEnd_234 + null + } + }) + + (this) { + position = idxFieldEnd + if (delimiter == ",") 1 else lineBreak.length +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#position. +// ^^^^^^^^^^^ reference local idxFieldEnd_230 +// ^^^^^^^^^ reference local delimiter_231 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#lineBreak. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + when (delimiter != "," || nullEnd) { +// ^^^^^^^^^ reference local delimiter_231 +// ^^^^^^^ reference local nullEnd_234 + rows { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#rows. + newRow.toList() +// ^^^^^^ reference local newRow_237 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + } + currentRow = new {} +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#currentRow. + } else { + currentRow = newRow +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#currentRow. +// ^^^^^^ reference local newRow_237 + } + }.parseResult +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#parseResult. + + function findValueEndIndex(position: UInt): UInt = +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#findValueEndIndex(). +// ^^^^^^^^ definition local position_256 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + let (remainingPositions = IntSeq(position, input.length - 1)) +// ^^^^^^^^^^^^^^^^^^ definition local remainingPositions_257 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). +// ^^^^^^^^ reference local position_256 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#input. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + remainingPositions.fold(Pair(position, false), (state, currentPos) -> +// ^^^^^^^^^^^^^^^^^^ reference local remainingPositions_257 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq#fold(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^^^ reference local position_256 +// ^^^^^ definition local state_258 +// ^^^^^^^^^^ definition local currentPos_258 + let (searchPos = state.first) +// ^^^^^^^^^ definition local searchPos_259 +// ^^^^^ reference local state_258 + let (found = state.second) +// ^^^^^ definition local found_260 +// ^^^^^ reference local state_258 + if (found || currentPos < searchPos) +// ^^^^^ reference local found_260 +// ^^^^^^^^^^ reference local currentPos_258 +// ^^^^^^^^^ reference local searchPos_259 + state // Already found or haven't reached search position yet +// ^^^^^ reference local state_258 + else + let (characterAtPosition = input.getOrNull(currentPos)) +// ^^^^^^^^^^^^^^^^^^^ definition local characterAtPosition_264 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#input. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#getOrNull(). +// ^^^^^^^^^^ reference local currentPos_258 + new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["\""] = + if (input.getOrNull(currentPos + 1) == "\"") +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/StringyTableParser#input. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#getOrNull(). +// ^^^^^^^^^^ reference local currentPos_258 + Pair(currentPos + 2, false) // Escaped quote, skip ahead by 2 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^^^^^ reference local currentPos_258 + else + Pair(currentPos, true) // Found unescaped quote, this is the end +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^^^^^ reference local currentPos_258 + [null] = throw("Premature end of quoted field") + }.getOrNull(characterAtPosition) ?? Pair(currentPos + 1, false) // Continue searching, advance by 1 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^^^^^^^^^^^^^^ reference local characterAtPosition_264 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^^^^^^^ reference local currentPos_258 + ).first +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + } + diff --git a/pkl-pantrysnapshot/pkl.csv/tests/csv_test.pkl b/pkl-pantrysnapshot/pkl.csv/tests/csv_test.pkl new file mode 100755 index 00000000..b606f6a2 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.csv/tests/csv_test.pkl @@ -0,0 +1,506 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.csv.tests.csv_test +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/ + + amends "pkl:test" + + import "../csv.pkl" + + // Rendering functions + local renderer = new csv.Renderer {} +// ^^^^^^^^ definition local renderer_23 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer# + local function value(val: csv.Value): String = renderer.renderValue(val) +// ^^^^^ definition local value_24 +// ^^^ definition local val_24 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Value# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference local renderer_23 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderValue(). +// ^^^ reference local val_24 + local function doc(val: csv.ListLike): String = renderer.renderDocument(val) +// ^^^ definition local doc_25 +// ^^^ definition local val_25 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/ListLike# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference local renderer_23 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderDocument(). +// ^^^ reference local val_25 + local function anon(val: csv.ListLike): String = (renderer) { includeHeader = false }.renderDocument(val) +// ^^^^ definition local anon_26 +// ^^^ definition local val_26 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/ListLike# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference local renderer_23 +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/includeHeader. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderDocument(). +// ^^^ reference local val_26 + local function pad(val: csv.ListLike) = (renderer) { unification = "pad" }.renderDocument(val) +// ^^^ definition local pad_27 +// ^^^ definition local val_27 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/ListLike# +// ^^^^^^^^ reference local renderer_23 +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/unification. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderDocument(). +// ^^^ reference local val_27 + local function drop(val: csv.ListLike) = (renderer) { unification = "drop" }.renderDocument(val) +// ^^^^ definition local drop_28 +// ^^^ definition local val_28 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/ListLike# +// ^^^^^^^^ reference local renderer_23 +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/unification. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderDocument(). +// ^^^ reference local val_28 + local function error(val: csv.ListLike) = (renderer) { unification = "error" }.renderDocument(val) +// ^^^^^ definition local error_29 +// ^^^ definition local val_29 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/ListLike# +// ^^^^^^^^ reference local renderer_23 +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/unification. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderDocument(). +// ^^^ reference local val_29 + + local parser = new csv.Parser {} +// ^^^^^^ definition local parser_31 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser# + local function pValue(_input: String): csv.Value = +// ^^^^^^ definition local pValue_32 +// ^^^^^^ definition local _input_32 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Value# + let (lineBreak = "\r\n") +// ^^^^^^^^^ definition local lineBreak_33 + let (table = (parser) { input = _input + lineBreak }.parsed.toList()) +// ^^^^^ definition local table_34 +// ^^^^^^ reference local parser_31 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/input. +// ^^^^^^ reference local _input_32 +// ^^^^^^^^^ reference local lineBreak_33 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#parsed. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toList(). + if (table.length != 1 || table.first.toList().length != 1) +// ^^^^^ reference local table_34 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^ reference local table_34 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. + throw("When parsing '\(_input)', expecting a single row, with a single column, but found \(table.length) rows and \(table.firstOrNull?.toList()?.length) columns") +// ^^^^^^ reference local _input_32 +// ^^^^^ reference local table_34 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^ reference local table_34 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#firstOrNull. + else + table.first.toList().first +// ^^^^^ reference local table_34 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. + + local values = new Mapping> { +// ^^^^^^ definition local values_40 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Value# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + ["string"] = new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + ["some string"] = "some string" + [#"string with "quotes""#] = #""string with ""quotes""""# + ["a string, with a comma"] = #""a string, with a comma""# + ["a multiline\nstring"] = "a multiline\nstring" + ["a multiline\r\nstring with carriage return"] = #""a multiline\#r\#nstring with carriage return""# + ["\""] = "\"\"\"\"" + ["\t\\\r"] = "\t\\\r" + } + ["number"] = new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + [0] = "0" + [42] = "42" + [-1] = "-1" + [0.42] = "0.42" + [-1.0] = "-1.0" + } + ["other"] = new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + [true] = "true" + [false] = "false" + [null] = "" + } + } + + local exampleTable = new Listing { +// ^^^^^^^^^^^^ definition local exampleTable_64 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + default = (i) -> new Dynamic { lineNumber = i description = "This is line \(i) of the table" } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/default. +// ^ definition local i_65 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/lineNumber. +// ^ reference local i_65 +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/description. +// ^ reference local i_65 + for (_ in IntSeq(1, 5)) { +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). + new {} + } + } + + local typealias MyTypeAlias = *String|Int +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/MyTypeAlias# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + local open class Base { +// ^^^^ definition local Base_73 + hidden quoted: Boolean = false +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/Base#quoted. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + local quote = if (quoted) "\"" else "" +// ^^^^^ definition local quote_75 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/Base#quoted. + foo: MyTypeAlias = "FOO!" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/Base#foo. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/MyTypeAlias# + bar: String = "Just wanted to say \(quote)hello\(quote)" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/Base#bar. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference local quote_75 +// ^^^^^ reference local quote_75 + baz: Int = -42 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/Base#baz. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + qux: Float = 0.1337 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/Base#qux. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + } + + local class DerivedOne extends Base { +// ^^^^^^^^^^ definition local DerivedOne_82 +// ^^^^ reference local Base_73 + quux: Number = -0.42 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/DerivedOne#quux. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + } + + local class DerivedTwo extends Base { +// ^^^^^^^^^^ definition local DerivedTwo_86 +// ^^^^ reference local Base_73 + corge: Boolean = false +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/DerivedTwo#corge. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + local homogeneousListing = new Listing { +// ^^^^^^^^^^^^^^^^^^ definition local homogeneousListing_90 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference local DerivedTwo_86 + new { foo = "first row" } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/foo. + new { foo = "second\nrow" } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/foo. + new { baz = 0 } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/baz. + new { qux = 1.337 } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/qux. + } + + local heterogeneousListing = new Listing { +// ^^^^^^^^^^^^^^^^^^^^ definition local heterogeneousListing_97 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference local Base_73 + new DerivedTwo {} +// ^^^^^^^^^^ reference local DerivedTwo_86 + new Base { quoted = true } +// ^^^^ reference local Base_73 +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/quoted. + new DerivedOne {} +// ^^^^^^^^^^ reference local DerivedOne_82 + new Base {} +// ^^^^ reference local Base_73 + } + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/facts. + for (category, cases in values) { +// ^^^^^^^^ definition local category_105 +// ^^^^^ definition local cases_105 +// ^^^^^^ reference local values_40 + ["Rendering \(category) values"] { +// ^^^^^^^^ reference local category_105 + for (value, rendered in cases) { +// ^^^^^ definition local value_107 +// ^^^^^^^^ definition local rendered_107 +// ^^^^^ reference local cases_105 + if (value(value) == rendered) true else let (_ = trace("\(value(value)) != \(rendered)")) false +// ^^^^^ reference local value_24 +// ^^^^^ reference local value_107 +// ^^^^^^^^ reference local rendered_107 +// ^^^^^ reference local value_24 +// ^^^^^ reference local value_107 +// ^^^^^^^^ reference local rendered_107 + } + } + + ["Parsing \(category) values"] { +// ^^^^^^^^ reference local category_105 + for (value, rendered in cases) { +// ^^^^^ definition local value_113 +// ^^^^^^^^ definition local rendered_113 +// ^^^^^ reference local cases_105 + pValue(rendered) == value?.toString() // because the parser does not have type information +// ^^^^^^ reference local pValue_32 +// ^^^^^^^^ reference local rendered_113 +// ^^^^^ reference local value_113 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#toString(). + } + } + } + + ["Rendering list(like) values"] { + anon(new Dynamic { new Dynamic { "foo" 1 false "bar" } }) == """ +// ^^^^ reference local anon_26 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + foo,1,false,bar + + """.replaceAll("\n", "\r\n") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + + doc(new Dynamic { new Dynamic { foo = 42 bar = false } }) == """ +// ^^^ reference local doc_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/foo. +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/bar. + foo,bar + 42,false + + """.replaceAll("\n", "\r\n") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + + doc(exampleTable) == """ +// ^^^ reference local doc_25 +// ^^^^^^^^^^^^ reference local exampleTable_64 + lineNumber,description + 0,This is line 0 of the table + 1,This is line 1 of the table + 2,This is line 2 of the table + 3,This is line 3 of the table + 4,This is line 4 of the table + + """.replaceAll("\n", "\r\n") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + + anon(exampleTable) == """ +// ^^^^ reference local anon_26 +// ^^^^^^^^^^^^ reference local exampleTable_64 + 0,This is line 0 of the table + 1,This is line 1 of the table + 2,This is line 2 of the table + 3,This is line 3 of the table + 4,This is line 4 of the table + + """.replaceAll("\n", "\r\n") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + } + + ["Rendering polymorphic lists; unifications"] { + pad(heterogeneousListing) == #""" +// ^^^ reference local pad_27 +// ^^^^^^^^^^^^^^^^^^^^ reference local heterogeneousListing_97 + foo,bar,baz,qux,corge,quux + FOO!,Just wanted to say hello,-42,0.1337,false, + FOO!,"Just wanted to say ""hello""",-42,0.1337,, + FOO!,Just wanted to say hello,-42,0.1337,,-0.42 + FOO!,Just wanted to say hello,-42,0.1337,, + + """#.replaceAll("\n", "\r\n") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + + drop(heterogeneousListing) == #""" +// ^^^^ reference local drop_28 +// ^^^^^^^^^^^^^^^^^^^^ reference local heterogeneousListing_97 + foo,bar,baz,qux,corge + FOO!,Just wanted to say hello,-42,0.1337,false + FOO!,"Just wanted to say ""hello""",-42,0.1337, + FOO!,Just wanted to say hello,-42,0.1337, + FOO!,Just wanted to say hello,-42,0.1337, + + """#.replaceAll("\n", "\r\n") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + + error(exampleTable) == doc(exampleTable) +// ^^^^^ reference local error_29 +// ^^^^^^^^^^^^ reference local exampleTable_64 +// ^^^ reference local doc_25 +// ^^^^^^^^^^^^ reference local exampleTable_64 + + module.catch(() -> error(heterogeneousListing)) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^ reference local error_29 +// ^^^^^^^^^^^^^^^^^^^^ reference local heterogeneousListing_97 + .startsWith("Invalid input: CSV can only render rows with all the same properties.") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + } + + ["Rendering errors"] { + module.catch(() -> doc(new Dynamic { Map("foo", 1, "bar", 2) Map("foo", 1) })) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^ reference local doc_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + .startsWith("Invalid input: CSV can only render rows with all the same properties.") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + } + + ["Parsing with header information"] { + // A little finicky, but if the parser doesn't have type information, every _value_ comes out stringy. + new csv.Parser { +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser# + input = """ +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/input. + foo,bar,baz,qux,corge\r + first row,Just wanted to say hello,-42,0.1337,false\r + second + row,Just wanted to say hello,-42,0.1337,false\r + FOO!,Just wanted to say hello,0,0.1337,false\r + FOO!,Just wanted to say hello,-42,1.337,false\r + + """ + includeHeader = true +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/includeHeader. + }.parsed == new Listing { +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#parsed. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + for (row in homogeneousListing) { +// ^^^ definition local row_195 +// ^^^^^^^^^^^^^^^^^^ reference local homogeneousListing_90 + row.toDynamic().toMap().mapValues((_, v) -> v.toString()).toDynamic() +// ^^^ reference local row_195 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toDynamic(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#mapValues(). +// ^ definition local v_196 +// ^ reference local v_196 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toDynamic(). + } + }.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + + new csv.Parser { +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser# + input = """ +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/input. + foo,bar,baz,qux,corge\r + first row,Just wanted to say hello,-42,0.1337,false\r + second + row,Just wanted to say hello,-42,0.1337,false\r + FOO!,Just wanted to say hello,0,0.1337,false\r + FOO!,Just wanted to say hello,-42,1.337,false\r + + """ + rowClass = DerivedTwo +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/rowClass. +// ^^^^^^^^^^ reference local DerivedTwo_86 + includeHeader = true +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/includeHeader. + }.parsed == homogeneousListing.toList() +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#parsed. +// ^^^^^^^^^^^^^^^^^^ reference local homogeneousListing_90 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + } + + ["Parsing with class, without header information"] { + new csv.Parser { +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser# + input = anon(homogeneousListing) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/input. +// ^^^^ reference local anon_26 +// ^^^^^^^^^^^^^^^^^^ reference local homogeneousListing_90 + rowClass = DerivedTwo +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/rowClass. +// ^^^^^^^^^^ reference local DerivedTwo_86 + includeHeader = false +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/includeHeader. + }.parsed == homogeneousListing.toList() +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#parsed. +// ^^^^^^^^^^^^^^^^^^ reference local homogeneousListing_90 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + } + + ["Rendering and parsing CRLF alternatives"] { + for (break in List("\n", "\r", "\t", "😀", "\r\r\n\n")) { +// ^^^^^ definition local break_224 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + ...new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + local quote = if (break == "\n") "\"" else "" +// ^^^^^ definition local quote_226 +// ^^^^^ reference local break_224 + local source = """ +// ^^^^^^ definition local source_227 + foo,bar,baz,qux,corge\r + first row,Just wanted to say hello,-42,0.1337,false\r + \(quote)second +// ^^^^^ reference local quote_226 + row\(quote),Just wanted to say hello,-42,0.1337,false\r +// ^^^^^ reference local quote_226 + FOO!,Just wanted to say hello,0,0.1337,false\r + FOO!,Just wanted to say hello,-42,1.337,false\r + + """.replaceAll("\r\n", break) +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). +// ^^^^^ reference local break_224 + + new csv.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer# + lineBreak = break +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/lineBreak. +// ^^^^^ reference local break_224 + }.renderDocument(homogeneousListing) == source +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Renderer#renderDocument(). +// ^^^^^^^^^^^^^^^^^^ reference local homogeneousListing_90 +// ^^^^^^ reference local source_227 + + new csv.Parser { +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser# + input = source +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/input. +// ^^^^^^ reference local source_227 + rowClass = DerivedTwo +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/rowClass. +// ^^^^^^^^^^ reference local DerivedTwo_86 + includeHeader = true +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/includeHeader. + lineBreak = break +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `tests/csv_test.pkl`/lineBreak. +// ^^^^^ reference local break_224 + }.parsed == homogeneousListing.toList() +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.csv 1.1.0 `csv.pkl`/Parser#parsed. +// ^^^^^^^^^^^^^^^^^^ reference local homogeneousListing_90 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + } + } + } + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.deepToTyped/PklProject b/pkl-pantrysnapshot/pkl.experimental.deepToTyped/PklProject new file mode 100755 index 00000000..c483982e --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.deepToTyped/PklProject @@ -0,0 +1,24 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// An experimental module that does a deep-conversion of [Dynamic] into [Typed]. + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 PklProject/package. + version = "1.1.1" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.deepToTyped/deepToTyped.pkl b/pkl-pantrysnapshot/pkl.experimental.deepToTyped/deepToTyped.pkl new file mode 100755 index 00000000..c3f9f846 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.deepToTyped/deepToTyped.pkl @@ -0,0 +1,928 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.deepToTyped.deepToTyped +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ + + import "pkl:reflect" + + /// Takes a given structure `Any` and coerces it into a concrete type `Class|TypeAlias`. + /// + /// Facts: + /// ``` + /// local class Foo { x: Int } + /// local class Bar { foo: Foo } + /// local dynamicBar = new Dynamic { foo { x = 1 } } + /// apply(Bar, dynamicBar) == new Bar { foo = new Foo { x = 1 } } + /// ``` + function apply(type: Class|TypeAlias, value: Any): Any = +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// documentation +// > Takes a given structure `Any` and coerces it into a concrete type `Class|TypeAlias`. +// > +// > Facts: +// > ``` +// > local class Foo { x: Int } +// > local class Bar { foo: Foo } +// > local dynamicBar = new Dynamic { foo { x = 1 } } +// > apply(Bar, dynamicBar) == new Bar { foo = new Foo { x = 1 } } +// > ``` +// ^^^^ definition local type_29 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# +// ^^^^^ definition local value_29 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + let (result = +// ^^^^^^ definition local result_30 + attemptApply(type, value) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/attemptApply(). +// ^^^^ reference local type_29 +// ^^^^^ reference local value_29 + ) + if (result is ConversionFailure) throw(result.error) else result +// ^^^^^^ reference local result_30 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^^^^^ reference local result_30 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#error. +// ^^^^^^ reference local result_30 + + /// Same as [apply], but returns [ConversionFailure] rather than throwing. + function attemptApply(type: Class|TypeAlias, value: Any): Any|ConversionFailure = +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/attemptApply(). +// documentation +// > Same as `apply`, but returns [`ConversionFailure`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.deepToTyped/deepToTyped.pkl#L43,C7) rather than throwing. +// ^^^^ definition local type_36 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# +// ^^^^^ definition local value_36 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + if (type is Class) +// ^^^^ reference local type_36 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# + applyClass(reflect.Class(type), List(), value) +// ^^^^^^^^^^ reference local applyClass_128 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^^^^ reference local type_36 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^ reference local value_36 + else + applyType(reflect.TypeAlias(type).referent, value) +// ^^^^^^^^^ reference local applyType_224 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias(). +// ^^^^ reference local type_36 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias#referent. +// ^^^^^ reference local value_36 + + + class ConversionFailure { +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + fixed error = "\(message) (at path \(renderedPath))" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#error. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#message. +// ^^^^^^^^^^^^ reference local renderedPath_48 + message: String +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#message. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + path: Listing +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#path. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + local renderedPath = path.toList().reverse().fold("", (acc, v) -> +// ^^^^^^^^^^^^ definition local renderedPath_48 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#path. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#reverse(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^ definition local acc_48 +// ^ definition local v_48 + if (v is String) "\(acc).\(v)" else "\(acc)[\(v)]" +// ^ reference local v_48 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference local acc_48 +// ^ reference local v_48 +// ^^^ reference local acc_48 +// ^ reference local v_48 + ) + + function toMapping(): ConversionFailure = this +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#toMapping(). +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + function toListing(): ConversionFailure = this +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#toListing(). +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + function appendPath(_path: String) = (this) { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#appendPath(). +// ^^^^^ definition local _path_54 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + path { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#path. + _path +// ^^^^^ reference local _path_54 + } + } + function appendIndex(idx: Int) = (this) { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#appendIndex(). +// ^^^ definition local idx_59 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + path { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#path. + idx +// ^^^ reference local idx_59 + } + } + } + + function Fail(_message: String): ConversionFailure = new { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Fail(). +// ^^^^^^^^ definition local _message_66 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + message = _message +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/message. +// ^^^^^^^^ reference local _message_66 + } + + function Unexpected(expected: String, actual: String): ConversionFailure = +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^^^^ definition local expected_70 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ definition local actual_70 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + Fail(#"Expected "\#(expected)" but got "\#(actual)""#) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Fail(). +// ^^^^^^^^ reference local expected_70 +// ^^^^^^ reference local actual_70 + + hidden classHandlers: Mapping, Any) -> Any|ConversionFailure> = new { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/classHandlers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + [Mapping] = (typeArguments, value) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^ definition local typeArguments_74 +// ^^^^^ definition local value_74 + if (value is Dynamic|Map|Mapping) +// ^^^^^ reference local value_74 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + applyMapping(typeArguments.firstOrNull ?? reflect.unknownType, typeArguments.getOrNull(1) ?? reflect.unknownType, value) +// ^^^^^^^^^^^^ reference local applyMapping_241 +// ^^^^^^^^^^^^^ reference local typeArguments_74 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#firstOrNull. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/unknownType. +// ^^^^^^^^^^^^^ reference local typeArguments_74 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#getOrNull(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/unknownType. +// ^^^^^ reference local value_74 + else + Unexpected("Dynamic|Map|Mapping", value.getClass().simpleName) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^ reference local value_74 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + [Map] = (typeArguments, value) -> +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^^^^^^^ definition local typeArguments_80 +// ^^^^^ definition local value_80 + if (value is Dynamic|Map|Mapping) +// ^^^^^ reference local value_80 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + applyMap(typeArguments.firstOrNull ?? reflect.unknownType, typeArguments.getOrNull(1) ?? reflect.unknownType, value) +// ^^^^^^^^ reference local applyMap_231 +// ^^^^^^^^^^^^^ reference local typeArguments_80 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#firstOrNull. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/unknownType. +// ^^^^^^^^^^^^^ reference local typeArguments_80 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#getOrNull(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/unknownType. +// ^^^^^ reference local value_80 + else + Unexpected("Dynamic|Map|Mapping", value.getClass().simpleName) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^ reference local value_80 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + [Listing] = (typeArguments, value) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ definition local typeArguments_86 +// ^^^^^ definition local value_86 + if (value is Dynamic|Collection|Listing) +// ^^^^^ reference local value_86 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Collection# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + applyListing(typeArguments.firstOrNull ?? reflect.unknownType, value.toList()) +// ^^^^^^^^^^^^ reference local applyListing_251 +// ^^^^^^^^^^^^^ reference local typeArguments_86 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#firstOrNull. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/unknownType. +// ^^^^^ reference local value_86 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + else + Unexpected("Dynamic|Collection|Listing", value.getClass().simpleName) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^ reference local value_86 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + [List] = (typeArguments, value) -> +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^^^^ definition local typeArguments_92 +// ^^^^^ definition local value_92 + if (value is Dynamic|Collection) +// ^^^^^ reference local value_92 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Collection# + applyList(typeArguments.firstOrNull ?? reflect.unknownType, value) +// ^^^^^^^^^ reference local applyList_244 +// ^^^^^^^^^^^^^ reference local typeArguments_92 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#firstOrNull. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/unknownType. +// ^^^^^ reference local value_92 + else + Unexpected("Dynamic|Collection", value.getClass().simpleName) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^ reference local value_92 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + [Set] = (typeArguments, value) -> +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^^^^^^^^^^ definition local typeArguments_98 +// ^^^^^ definition local value_98 + if (value is Dynamic|Collection) +// ^^^^^ reference local value_98 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Collection# + applyList(typeArguments.firstOrNull ?? reflect.unknownType, value).toSet() +// ^^^^^^^^^ reference local applyList_244 +// ^^^^^^^^^^^^^ reference local typeArguments_98 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#firstOrNull. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/unknownType. +// ^^^^^ reference local value_98 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toSet(). + else + Unexpected("Dynamic|Collection", value.getClass().simpleName) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^ reference local value_98 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + [Collection] = (typeArguments, value) -> +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Collection# +// ^^^^^^^^^^^^^ definition local typeArguments_104 +// ^^^^^ definition local value_104 + if (value is Dynamic|Collection) +// ^^^^^ reference local value_104 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Collection# + applyList(typeArguments.firstOrNull ?? reflect.unknownType, value) +// ^^^^^^^^^ reference local applyList_244 +// ^^^^^^^^^^^^^ reference local typeArguments_104 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#firstOrNull. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/unknownType. +// ^^^^^ reference local value_104 + else + Unexpected("Dynamic|Collection", value.getClass().simpleName) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^ reference local value_104 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + [Int] = (_, value) -> +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^ definition local value_110 + if (value is Int) value else Unexpected("Int", value.getClass().simpleName) +// ^^^^^ reference local value_110 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^ reference local value_110 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^ reference local value_110 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + [String] = (_, value) -> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local value_113 + if (value is String) value else Unexpected("String", value.getClass().simpleName) +// ^^^^^ reference local value_113 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference local value_113 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^ reference local value_113 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + [Float] = (_, value) -> +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# +// ^^^^^ definition local value_116 + if (value is Number) value.toFloat() else Unexpected("Float", value.getClass().simpleName) +// ^^^^^ reference local value_116 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^ reference local value_116 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#toFloat(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^ reference local value_116 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + [Number] = (_, value) -> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^ definition local value_119 + if (value is Number) value else Unexpected("Number", value.getClass().simpleName) +// ^^^^^ reference local value_119 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^ reference local value_119 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^ reference local value_119 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + [Boolean] = (_, value) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^ definition local value_122 + if (value is Boolean) value else Unexpected("Boolean", value.getClass().simpleName) +// ^^^^^ reference local value_122 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^ reference local value_122 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^ reference local value_122 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + [Any] = (_, value) -> value +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^ definition local value_125 +// ^^^^^ reference local value_125 + } + + local function applyClass(type: reflect.Class, typeArguments: List, value: Any): Any|ConversionFailure = +// ^^^^^^^^^^ definition local applyClass_128 +// ^^^^ definition local type_128 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# +// ^^^^^^^^^^^^^ definition local typeArguments_128 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^ definition local value_128 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + let (clazz = type.reflectee) +// ^^^^^ definition local clazz_129 +// ^^^^ reference local type_128 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#reflectee. + if (classHandlers.containsKey(clazz)) +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/classHandlers. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). +// ^^^^^ reference local clazz_129 + classHandlers[clazz].apply(typeArguments, value) +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/classHandlers. +// ^^^^^ reference local clazz_129 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function2#apply(). +// ^^^^^^^^^^^^^ reference local typeArguments_128 +// ^^^^^ reference local value_128 + else if (type.isSubclassOf(reflect.Class(Typed))) +// ^^^^ reference local type_128 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#isSubclassOf(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# + applyTyped(type, value) +// ^^^^^^^^^^ reference local applyTyped_169 +// ^^^^ reference local type_128 +// ^^^^^ reference local value_128 + else + Fail("Unsupported type for conversion: \(type.reflectee.simpleName)") +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Fail(). +// ^^^^ reference local type_128 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#reflectee. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + local function doesNotInherit(clazz: reflect.Class) = +// ^^^^^^^^^^^^^^ definition local doesNotInherit_137 +// ^^^^^ definition local clazz_137 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# + clazz.superclass == null || clazz.superclass.reflectee == Module || clazz.superclass.reflectee == Typed +// ^^^^^ reference local clazz_137 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#superclass. +// ^^^^^ reference local clazz_137 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#superclass. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#reflectee. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module# +// ^^^^^ reference local clazz_137 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#superclass. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#reflectee. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# + + local function getAllProperties(clazz: reflect.Class?): Map = +// ^^^^^^^^^^^^^^^^ definition local getAllProperties_140 +// ^^^^^ definition local clazz_140 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# + if (clazz == null) Map() +// ^^^^^ reference local clazz_140 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + else if (doesNotInherit(clazz)) clazz.properties +// ^^^^^^^^^^^^^^ reference local doesNotInherit_137 +// ^^^^^ reference local clazz_140 +// ^^^^^ reference local clazz_140 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#properties. + else getAllProperties(clazz.superclass!!) + clazz.properties +// ^^^^^^^^^^^^^^^^ reference local getAllProperties_140 +// ^^^^^ reference local clazz_140 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#superclass. +// ^^^^^ reference local clazz_140 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#properties. + + hidden keyTransform: Function1? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/keyTransform. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + local function applyProperty(valueAsMap: Map, prop: reflect.Property) = +// ^^^^^^^^^^^^^ definition local applyProperty_147 +// ^^^^^^^^^^ definition local valueAsMap_147 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^ definition local prop_147 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# + let (propName = keyTransform?.ifNonNull((it) -> (it as Function1).apply(prop)) ?? prop.name) +// ^^^^^^^^ definition local propName_148 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/keyTransform. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_148 +// ^^ reference local it_148 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^ reference local prop_147 +// ^^^^ reference local prop_147 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#name. + if (valueAsMap.containsKey(propName)) applyType(prop.type, valueAsMap[propName]) +// ^^^^^^^^^^ reference local valueAsMap_147 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#containsKey(). +// ^^^^^^^^ reference local propName_148 +// ^^^^^^^^^ reference local applyType_224 +// ^^^^ reference local prop_147 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^ reference local valueAsMap_147 +// ^^^^^^^^ reference local propName_148 + else if (!(prop.type is reflect.NullableType) && prop.defaultValue != null) prop.defaultValue +// ^^^^ reference local prop_147 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType# +// ^^^^ reference local prop_147 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#defaultValue. +// ^^^^ reference local prop_147 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#defaultValue. + else null + + local function applyDynamicOrMapping(type: reflect.Class, value: Dynamic|Mapping): Typed|ConversionFailure = +// ^^^^^^^^^^^^^^^^^^^^^ definition local applyDynamicOrMapping_153 +// ^^^^ definition local type_153 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# +// ^^^^^ definition local value_153 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + let (valueAsMap = value.toMap()) +// ^^^^^^^^^^ definition local valueAsMap_154 +// ^^^^^ reference local value_153 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + let (converted = getAllProperties(type) +// ^^^^^^^^^ definition local converted_155 +// ^^^^^^^^^^^^^^^^ reference local getAllProperties_140 +// ^^^^ reference local type_153 + .fold( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#fold(). + Map(), +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + (acc: Map|ConversionFailure, name: String, prop: reflect.Property) -> +// ^^^ definition local acc_158 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^^^ definition local name_158 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ definition local prop_158 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# + // Fixed properties are automatically initialised by `toTyped` + if (acc is ConversionFailure || prop.modifiers.contains("fixed")) +// ^^^ reference local acc_158 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^^^ reference local prop_158 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#modifiers. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). + acc +// ^^^ reference local acc_158 + else + let (result = applyProperty(valueAsMap, prop)) +// ^^^^^^ definition local result_163 +// ^^^^^^^^^^^^^ reference local applyProperty_147 +// ^^^^^^^^^^ reference local valueAsMap_154 +// ^^^^ reference local prop_158 + if (result is ConversionFailure) result.appendPath(name) else acc.put(name, result) +// ^^^^^^ reference local result_163 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^^^^^ reference local result_163 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#appendPath(). +// ^^^^ reference local name_158 +// ^^^ reference local acc_158 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#put(). +// ^^^^ reference local name_158 +// ^^^^^^ reference local result_163 + ) + ) + if (converted is ConversionFailure) converted else converted.toTyped(type.reflectee) +// ^^^^^^^^^ reference local converted_155 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^^^^^^^^ reference local converted_155 +// ^^^^^^^^^ reference local converted_155 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toTyped(). +// ^^^^ reference local type_153 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#reflectee. + + local function applyTyped(type: reflect.Class, value: Any): Typed|ConversionFailure = +// ^^^^^^^^^^ definition local applyTyped_169 +// ^^^^ definition local type_169 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# +// ^^^^^ definition local value_169 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + if (value is Dynamic|Mapping) applyDynamicOrMapping(type, value) +// ^^^^^ reference local value_169 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^^^^^^^^ reference local applyDynamicOrMapping_153 +// ^^^^ reference local type_169 +// ^^^^^ reference local value_169 + else if (value is Typed && value.getClass() == type.reflectee) value +// ^^^^^ reference local value_169 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^^ reference local value_169 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^ reference local type_169 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#reflectee. +// ^^^^^ reference local value_169 + else Unexpected(type.name, value.getClass().simpleName) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^ reference local type_169 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Declaration#name. +// ^^^^^ reference local value_169 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + hidden reflectTypeHandlers: Mapping Any|ConversionFailure> = new Mapping { +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/reflectTypeHandlers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + [reflect.DeclaredType] = (type, value) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# +// ^^^^ definition local type_175 +// ^^^^^ definition local value_175 + let (_type = type as reflect.DeclaredType) +// ^^^^^ definition local _type_176 +// ^^^^ reference local type_175 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# + let (reflectee = _type.referent.reflectee) +// ^^^^^^^^^ definition local reflectee_177 +// ^^^^^ reference local _type_176 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. + if (reflectee is Class) +// ^^^^^^^^^ reference local reflectee_177 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# + applyClass(reflect.Class(reflectee), _type.typeArguments, value) +// ^^^^^^^^^^ reference local applyClass_128 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^^^^^^^^^ reference local reflectee_177 +// ^^^^^ reference local _type_176 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#typeArguments. +// ^^^^^ reference local value_175 + else + // TODO: Assert that typeParameters.isEmpty?? + applyType(reflect.TypeAlias(reflectee).referent, value) +// ^^^^^^^^^ reference local applyType_224 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias(). +// ^^^^^^^^^ reference local reflectee_177 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias#referent. +// ^^^^^ reference local value_175 + + [reflect.StringLiteralType] = (type, value) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType# +// ^^^^ definition local type_184 +// ^^^^^ definition local value_184 + let (expected = (type as reflect.StringLiteralType).value) +// ^^^^^^^^ definition local expected_185 +// ^^^^ reference local type_184 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/StringLiteralType#value. + if (value is String) +// ^^^^^ reference local value_184 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (value == expected) +// ^^^^^ reference local value_184 +// ^^^^^^^^ reference local expected_185 + value +// ^^^^^ reference local value_184 + else + Unexpected(expected, value) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^^^^ reference local expected_185 +// ^^^^^ reference local value_184 + else + Unexpected(expected, value.getClass().simpleName) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Unexpected(). +// ^^^^^^^^ reference local expected_185 +// ^^^^^ reference local value_184 + + [reflect.UnionType] = (type, value) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType# +// ^^^^ definition local type_194 +// ^^^^^ definition local value_194 + (type as reflect.UnionType).members.fold( +// ^^^^ reference local type_194 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnionType#members. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). + Fail("No member of union type matched value '\(value)'"), +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Fail(). +// ^^^^^ reference local value_194 + (acc, _type) -> +// ^^^ definition local acc_197 +// ^^^^^ definition local _type_197 + if (acc is ConversionFailure) +// ^^^ reference local acc_197 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + let (attempt = applyType(_type, value)) +// ^^^^^^^ definition local attempt_199 +// ^^^^^^^^^ reference local applyType_224 +// ^^^^^ reference local _type_197 +// ^^^^^ reference local value_194 + if (attempt is ConversionFailure) acc else attempt +// ^^^^^^^ reference local attempt_199 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^^ reference local acc_197 +// ^^^^^^^ reference local attempt_199 + else + acc +// ^^^ reference local acc_197 + ) + + [reflect.NullableType] = (type, value) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType# +// ^^^^ definition local type_205 +// ^^^^^ definition local value_205 + if (value == null) null else applyType((type as reflect.NullableType).member, value) +// ^^^^^ reference local value_205 +// ^^^^^^^^^ reference local applyType_224 +// ^^^^ reference local type_205 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType#member. +// ^^^^^ reference local value_205 + + [reflect.FunctionType] = (_, _) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/FunctionType# + Fail("Cannot convert function types") +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Fail(). + + [reflect.ModuleType] = (_, _) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ModuleType# + Fail("unimplmeneted") +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Fail(). + + [reflect.UnknownType] = (_, value) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnknownType# +// ^^^^^ definition local value_214 + value +// ^^^^^ reference local value_214 + + [reflect.NothingType] = (_, _) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NothingType# + Fail("Cannot convert anything to `nothing`") +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Fail(). + + [reflect.TypeVariable] = (type, value) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeVariable# +// ^^^^ definition local type_220 +// ^^^^^ definition local value_220 + Fail("The type variable `\(type)` is unbound when trying to convert `\(value)`") +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Fail(). +// ^^^^ reference local type_220 +// ^^^^^ reference local value_220 + } + + local function applyType(type: reflect.Type, value: Any): Any|ConversionFailure = +// ^^^^^^^^^ definition local applyType_224 +// ^^^^ definition local type_224 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^ definition local value_224 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + let (clazz = type.getClass()) +// ^^^^^ definition local clazz_225 +// ^^^^ reference local type_224 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + if (reflectTypeHandlers.containsKey(clazz)) +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/reflectTypeHandlers. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). +// ^^^^^ reference local clazz_225 + reflectTypeHandlers[clazz].apply(type, value) +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/reflectTypeHandlers. +// ^^^^^ reference local clazz_225 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function2#apply(). +// ^^^^ reference local type_224 +// ^^^^^ reference local value_224 + else + Fail("Unknown reflect.Type: \(type.getClass().simpleName)") +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/Fail(). +// ^^^^ reference local type_224 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + + local function applyMap(keyType: reflect.Type, valueType: reflect.Type, value: Dynamic|Map|Mapping): Map|ConversionFailure = +// ^^^^^^^^ definition local applyMap_231 +// ^^^^^^^ definition local keyType_231 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^^^^^ definition local valueType_231 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^ definition local value_231 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + let (_value = if (value is Map) value else value.toMap()) +// ^^^^^^ definition local _value_232 +// ^^^^^ reference local value_231 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^ reference local value_231 +// ^^^^^ reference local value_231 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + _value.fold(Map(), (acc, k, v) -> if (acc is ConversionFailure) acc else +// ^^^^^^ reference local _value_232 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#fold(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^ definition local acc_233 +// ^ definition local k_233 +// ^ definition local v_233 +// ^^^ reference local acc_233 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^^ reference local acc_233 + let (_k = applyType(keyType, k)) +// ^^ definition local _k_234 +// ^^^^^^^^^ reference local applyType_224 +// ^^^^^^^ reference local keyType_231 +// ^ reference local k_233 + if (_k is ConversionFailure) _k else +// ^^ reference local _k_234 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^ reference local _k_234 + let (_v = applyType(valueType, v)) +// ^^ definition local _v_236 +// ^^^^^^^^^ reference local applyType_224 +// ^^^^^^^^^ reference local valueType_231 +// ^ reference local v_233 + if (_v is ConversionFailure) _v else +// ^^ reference local _v_236 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^ reference local _v_236 + acc.put(_k, _v) +// ^^^ reference local acc_233 +// ^^ reference local _k_234 +// ^^ reference local _v_236 + ) + + local function applyMapping(keyType: reflect.Type, valueType: reflect.Type, value: Dynamic|Map|Mapping): Mapping|ConversionFailure = +// ^^^^^^^^^^^^ definition local applyMapping_241 +// ^^^^^^^ definition local keyType_241 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^^^^^ definition local valueType_241 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^ definition local value_241 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + applyMap(keyType, valueType, value).toMapping() +// ^^^^^^^^ reference local applyMap_231 +// ^^^^^^^ reference local keyType_241 +// ^^^^^^^^^ reference local valueType_241 +// ^^^^^ reference local value_241 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#toMapping(). + + local function applyList(type: reflect.Type, value: Dynamic|Collection): List|ConversionFailure = +// ^^^^^^^^^ definition local applyList_244 +// ^^^^ definition local type_244 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^ definition local value_244 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Collection# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + value.toList().foldIndexed(List(), (idx: Int, acc: List|ConversionFailure, v) -> if (acc is ConversionFailure) acc else +// ^^^^^ reference local value_244 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Collection#toList(). +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#foldIndexed(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^ definition local idx_245 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^ definition local acc_245 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^ definition local v_245 +// ^^^ reference local acc_245 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^^ reference local acc_245 + let (_v = applyType(type, v)) +// ^^ definition local _v_246 +// ^^^^^^^^^ reference local applyType_224 +// ^^^^ reference local type_244 +// ^ reference local v_245 + if (_v is ConversionFailure) _v.appendIndex(idx) else +// ^^ reference local _v_246 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# +// ^^ reference local _v_246 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#appendIndex(). +// ^^^ reference local idx_245 + acc.add(_v) +// ^^^ reference local acc_245 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^ reference local _v_246 + ) + + local function applyListing(type: reflect.Type, value: Dynamic|Collection): Listing|ConversionFailure = +// ^^^^^^^^^^^^ definition local applyListing_251 +// ^^^^ definition local type_251 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Type# +// ^^^^^ definition local value_251 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Collection# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure# + applyList(type, value).toListing() +// ^^^^^^^^^ reference local applyList_244 +// ^^^^ reference local type_251 +// ^^^^^ reference local value_251 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ConversionFailure#toListing(). + diff --git a/pkl-pantrysnapshot/pkl.experimental.deepToTyped/tests/deepToTyped.pkl b/pkl-pantrysnapshot/pkl.experimental.deepToTyped/tests/deepToTyped.pkl new file mode 100755 index 00000000..8b0d3730 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.deepToTyped/tests/deepToTyped.pkl @@ -0,0 +1,759 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.deepToTyped.tests.deepToTyped +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/ + + amends "pkl:test" + + import "../deepToTyped.pkl" as t + + local class Foo { +// ^^^ definition local Foo_22 + x: Int +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/Foo#x. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + } + + local class Bar { +// ^^^ definition local Bar_26 + foo: Foo +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/Bar#foo. +// ^^^ reference local Foo_22 + } + + local class Baz { +// ^^^ definition local Baz_30 + y: Int +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/Baz#y. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + baz: Baz? +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/Baz#baz. +// ^^^ reference local Baz_30 + } + + local dynamic: Dynamic = new Dynamic { +// ^^^^^^^ definition local dynamic_35 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + foo { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/foo. + x = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/x. + } + } + + local typealias FooBarMapping = Mapping//|Listing|Foo +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/FooBarMapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference local Foo_22 +// ^^^ reference local Bar_26 + local exMapping: FooBarMapping = new { +// ^^^^^^^^^ definition local exMapping_42 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/FooBarMapping# + [new Foo { x = 42 }] { +// ^^^ reference local Foo_22 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/x. + foo { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/foo. + x = 1337 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/x. + } + } + } + + local typealias BarList = List +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarList# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^ reference local Bar_26 + local typealias BarListing = Listing +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarListing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^ reference local Bar_26 + local exListing: BarListing = new { +// ^^^^^^^^^ definition local exListing_52 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarListing# + new Bar { +// ^^^ reference local Bar_26 + foo { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/foo. + x = -1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/x. + } + } + } + + local typealias BarSet = Set +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarSet# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^ reference local Bar_26 + local exSet: BarSet = Set(new Bar { foo { x = 1 } }) +// ^^^^^ definition local exSet_61 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarSet# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set(). +// ^^^ reference local Bar_26 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/foo. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/x. + + local typealias BarUnionSetOrList = *BarSet|BarList +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarUnionSetOrList# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarSet# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarList# + + local class MyService { +// ^^^^^^^^^ definition local MyService_65 + metadata: MyMetadata +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/MyService#metadata. +// ^^^^^^^^^^ reference local MyMetadata_70 + spec: MySpec +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/MyService#spec. +// ^^^^^^ reference local MySpec_76 + } + + local class MyMetadata { +// ^^^^^^^^^^ definition local MyMetadata_70 + name: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/MyMetadata#name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + namespace: String +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/MyMetadata#namespace. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + labels: Mapping +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/MyMetadata#labels. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + local class MySpec { +// ^^^^^^ definition local MySpec_76 + type: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/MySpec#type. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + ports: Listing +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/MySpec#ports. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference local Port_82 + selector: Mapping +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/MySpec#selector. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + local class Port { +// ^^^^ definition local Port_82 + port: Int +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/Port#port. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + targetPort: Int +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/Port#targetPort. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + protocol: String +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/Port#protocol. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + local service: MyService = new { +// ^^^^^^^ definition local service_88 +// ^^^^^^^^^ reference local MyService_65 + metadata { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/metadata. + name = "example-service" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/name. + namespace = "example-namespace" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/namespace. + labels { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/labels. + ["app"] = "example" + ["env"] = "prod" + ["prtn"] = "p102" + } + } + spec { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/spec. + type = "ClusterIP" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/type. + ports { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/ports. + new { + port = 8080 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/port. + targetPort = 8080 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/targetPort. + protocol = "TCP" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/protocol. + } + } + selector { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/selector. + ["app"] = "example" + ["env"] = "prod" + ["prtn"] = "p102" + } + } + } + + local class OverConstrained { +// ^^^^^^^^^^^^^^^ definition local OverConstrained_115 + // k8s Deployment refers to k8s Probe, which has a type constraint on `exec` that excludes the default value of + // the Probe class; only one field of three may be `null` and all are, by default. + foo: String?(this != null || bar != null) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/OverConstrained#foo. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/OverConstrained#bar. + bar: Int? +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/OverConstrained#bar. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + } + + local typealias fooLiteral = "foo" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/fooLiteral# + local typealias enumType = *"foo"|"bar"|"baz" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/enumType# + + local class ClassWithDefaultAttribute { +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition local ClassWithDefaultAttribute_125 + what: String = "The default" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/ClassWithDefaultAttribute#what. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + who: String? +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/ClassWithDefaultAttribute#who. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + where: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/ClassWithDefaultAttribute#where. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + local open class BaseClass { +// ^^^^^^^^^ definition local BaseClass_131 + a: String +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BaseClass#a. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + b: String +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BaseClass#b. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + local class SubClass extends BaseClass { +// ^^^^^^^^ definition local SubClass_136 +// ^^^^^^^^^ reference local BaseClass_131 + // purposefully override `b`'s type to make sure we are converting correctly. + b: Int +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/SubClass#b. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + c: Int +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/SubClass#c. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + } + + local class Storage { +// ^^^^^^^ definition local Storage_142 + size: DataSize +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/Storage#size. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# + } + + local class LooselyTyped { +// ^^^^^^^^^^^^ definition local LooselyTyped_146 + anything: Any +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/LooselyTyped#anything. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + } + + local class KeyTransform extends Annotation { +// ^^^^^^^^^^^^ definition local KeyTransform_150 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Annotation# + name: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/KeyTransform#name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + local class ClassWithKeyTranform { +// ^^^^^^^^^^^^^^^^^^^^ definition local ClassWithKeyTranform_154 + @KeyTransform { name = "my_field" } +// ^^^^^^^^^^^^ reference local KeyTransform_150 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/ClassWithKeyTranform#name. + myField: String +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/ClassWithKeyTranform#myField. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + inner: InnerClassWithKeyTranform +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/ClassWithKeyTranform#inner. +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference local InnerClassWithKeyTranform_160 + } + + local class InnerClassWithKeyTranform { +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition local InnerClassWithKeyTranform_160 + @KeyTransform { name = "my_nested_field" } +// ^^^^^^^^^^^^ reference local KeyTransform_150 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/InnerClassWithKeyTranform#name. + myNestedField: String +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/InnerClassWithKeyTranform#myNestedField. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/facts. + ["Basic types"] { + t.apply(Int, 1) == 1 +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + t.apply(Float, 1) == 1 +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + t.apply(Float, 1.1) == 1.1 +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + t.apply(Number, 1) == 1 +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + t.apply(Boolean, true) == true +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + t.apply(String, "hello") == "hello" +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + t.apply(fooLiteral, "foo") == "foo" +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/fooLiteral# + t.apply(enumType, "bar") == "bar" +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/enumType# + } + + ["Listy types"] { + local list = new Listing { +// ^^^^ definition local list_178 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + "foo" + 42 + }.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + t.apply(List, list) == list +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^ reference local list_178 +// ^^^^ reference local list_178 + t.apply(Listing, list) == list.toListing() +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference local list_178 +// ^^^^ reference local list_178 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toListing(). + t.apply(Set, list) == list.toSet() +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^ reference local list_178 +// ^^^^ reference local list_178 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toSet(). + // There is a choice here: Abstract (!) supertype Collection defaults to List + t.apply(Collection, list) == list +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Collection# +// ^^^^ reference local list_178 +// ^^^^ reference local list_178 + } + + ["Mappy types"] { + local map = new Mapping { +// ^^^ definition local map_190 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["bar"] = "foo" + [0] = 42 + }.toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + t.apply(Map, map) == map +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^ reference local map_190 +// ^^^ reference local map_190 + t.apply(Mapping, map) == map.toMapping() +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference local map_190 +// ^^^ reference local map_190 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMapping(). + } + + ["Values of the correct Class type are returned"] { + t.apply(Foo, new Foo { x = 1 }) == new Foo { x = 1 } +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^ reference local Foo_22 +// ^^^ reference local Foo_22 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/x. +// ^^^ reference local Foo_22 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/x. + } + + ["Dynamic to user-defined class"] { + t.apply(Foo, dynamic.foo) == new Foo { x = 1 } +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^ reference local Foo_22 +// ^^^^^^^ reference local dynamic_35 +// ^^^ reference local Foo_22 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/x. + t.apply(Bar, dynamic) == new Bar { foo = new { x = 1 } } +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^ reference local Bar_26 +// ^^^^^^^ reference local dynamic_35 +// ^^^ reference local Bar_26 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/foo. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/x. + } + + ["Dynamic to concrete typealias"] { + t.apply(FooBarMapping, exMapping.toMap().toDynamic()) == exMapping +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/FooBarMapping# +// ^^^^^^^^^ reference local exMapping_42 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toDynamic(). +// ^^^^^^^^^ reference local exMapping_42 + t.apply(BarListing, exListing.toList().toDynamic()) == exListing +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarListing# +// ^^^^^^^^^ reference local exListing_52 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toDynamic(). +// ^^^^^^^^^ reference local exListing_52 + t.apply(BarList, exListing.toList().toDynamic()) == exListing.toList() +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarList# +// ^^^^^^^^^ reference local exListing_52 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toDynamic(). +// ^^^^^^^^^ reference local exListing_52 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + t.apply(BarSet, exSet.toDynamic()) == exSet +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarSet# +// ^^^^^ reference local exSet_61 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#toDynamic(). +// ^^^^^ reference local exSet_61 + } + + ["Dynamic to union typealias"] { + t.apply(BarUnionSetOrList, exSet) == exSet +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarUnionSetOrList# +// ^^^^^ reference local exSet_61 +// ^^^^^ reference local exSet_61 + t.apply(BarUnionSetOrList, exListing.toList()) is Collection +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/BarUnionSetOrList# +// ^^^^^^^^^ reference local exListing_52 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Collection# + } + + ["Service.toDynamic() to MyService"] { + t.apply(MyService, service.toDynamic()) == service +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^ reference local MyService_65 +// ^^^^^^^ reference local service_88 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toDynamic(). +// ^^^^^^^ reference local service_88 + } + + ["Service nested Dynamic to k8s Service"] { + local nestedDynamicService = new Dynamic { +// ^^^^^^^^^^^^^^^^^^^^ definition local nestedDynamicService_224 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + apiVersion = "v1" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/apiVersion. + kind = "Service" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/kind. + metadata { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/metadata. + name = "example-service" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/name. + namespace = "example-namespace" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/namespace. + labels { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/labels. + ["app"] = "example" + ["env"] = "prod" + ["prtn"] = "p102" + } + } + spec { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/spec. + type = "ClusterIP" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/type. + ports { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/ports. + new Dynamic { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + port = 8080 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/port. + targetPort = 8080 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/targetPort. + protocol = "TCP" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/protocol. + } + } + selector { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/selector. + ["app"] = "example" + ["env"] = "prod" + ["prtn"] = "p102" + } + } + } + t.apply(MyService, nestedDynamicService) == service +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^ reference local MyService_65 +// ^^^^^^^^^^^^^^^^^^^^ reference local nestedDynamicService_224 +// ^^^^^^^ reference local service_88 + } + + ["Negative cases"] { + // Something to think about: `y` is not in Foo; it quietly falls through here. + t.apply(Foo, new Dynamic { x = 42 y = 1337 }) == new Foo { x = 42 } +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^ reference local Foo_22 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/x. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/y. +// ^^^ reference local Foo_22 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/x. + } + + ["Type with fields that have dependent constraints"] { + local expectedOverconstrained = new OverConstrained { +// ^^^^^^^^^^^^^^^^^^^^^^^ definition local expectedOverconstrained_261 +// ^^^^^^^^^^^^^^^ reference local OverConstrained_115 + foo = "test" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/foo. + bar = null +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/bar. + } + + t.apply(OverConstrained, new Dynamic { foo = "test" }) == expectedOverconstrained +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^^^^^^ reference local OverConstrained_115 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/foo. +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local expectedOverconstrained_261 + } + + ["Class with default attribute gets set correctly"] { + local expectedClassWithDefault = new ClassWithDefaultAttribute { +// ^^^^^^^^^^^^^^^^^^^^^^^^ definition local expectedClassWithDefault_270 +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference local ClassWithDefaultAttribute_125 + who = "you!" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/who. + where = "here" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/where. + } + + expectedClassWithDefault.what == "The default" +// ^^^^^^^^^^^^^^^^^^^^^^^^ reference local expectedClassWithDefault_270 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/ClassWithDefaultAttribute#what. + + local input = new Dynamic { +// ^^^^^ definition local input_277 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + who = "you!" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/who. + where = "here" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/where. + } + + t.apply(ClassWithDefaultAttribute, input) == expectedClassWithDefault +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference local ClassWithDefaultAttribute_125 +// ^^^^^ reference local input_277 +// ^^^^^^^^^^^^^^^^^^^^^^^^ reference local expectedClassWithDefault_270 + } + + ["Correctly converts parent properties on a class"] { + local expectedResult: SubClass = new { +// ^^^^^^^^^^^^^^ definition local expectedResult_286 +// ^^^^^^^^ reference local SubClass_136 + a = "a" +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/a. + b = 2 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/b. + c = 3 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/c. + } + + local value = new { +// ^^^^^ definition local value_292 + a = "a" +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/a. + b = 2 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/b. + c = 3 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/c. + } + + t.apply(SubClass, value) == expectedResult +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^ reference local SubClass_136 +// ^^^^^ reference local value_292 +// ^^^^^^^^^^^^^^ reference local expectedResult_286 + } + + ["Report missing union type value"] { + module.catch(() -> t.apply(enumType, "non")).contains("'non'") +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/enumType# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + } + ["Custom handler allows converting custom types"] { + local expectedResult: Storage = new { +// ^^^^^^^^^^^^^^ definition local expectedResult_305 +// ^^^^^^^ reference local Storage_142 + size = 1024.b +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/size. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#b. + } + local value = new { +// ^^^^^ definition local value_308 + size = 1024 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/size. + } + // instantiate module as we need to amend it + new t { +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ + classHandlers { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/classHandlers. + [DataSize] = (_, value) -> (value as Int).toDataSize("b") +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/DataSize# +// ^^^^^ definition local value_314 +// ^^^^^ reference local value_314 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toDataSize(). + } + }.apply(Storage, value) == expectedResult +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^ reference local Storage_142 +// ^^^^^ reference local value_308 +// ^^^^^^^^^^^^^^ reference local expectedResult_305 + } + + ["Supports types containing Any"] { + local looselyTypedIntExpected: LooselyTyped = new { +// ^^^^^^^^^^^^^^^^^^^^^^^ definition local looselyTypedIntExpected_320 +// ^^^^^^^^^^^^ reference local LooselyTyped_146 + anything = 0 +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/anything. + } + local looselyTypedInt = new { +// ^^^^^^^^^^^^^^^ definition local looselyTypedInt_323 + anything = 0 +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/anything. + } + t.apply(LooselyTyped, looselyTypedInt) == looselyTypedIntExpected +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^^^ reference local LooselyTyped_146 +// ^^^^^^^^^^^^^^^ reference local looselyTypedInt_323 +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local looselyTypedIntExpected_320 + + local looselyTypedStringExpected: LooselyTyped = new { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition local looselyTypedStringExpected_328 +// ^^^^^^^^^^^^ reference local LooselyTyped_146 + anything = "anything" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/anything. + } + local looselyTypedString = new { +// ^^^^^^^^^^^^^^^^^^ definition local looselyTypedString_331 + anything = "anything" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/anything. + } + t.apply(LooselyTyped, looselyTypedString) == looselyTypedStringExpected +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^^^ reference local LooselyTyped_146 +// ^^^^^^^^^^^^^^^^^^ reference local looselyTypedString_331 +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local looselyTypedStringExpected_328 + } + + ["Supports key transformations, eg. via annotation"] { + local input = new Dynamic { +// ^^^^^ definition local input_338 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + my_field = "hello" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/my_field. + inner { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/inner. + my_nested_field = "world" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/my_nested_field. + } + } + + local expectedClassWithKeyTranform = new ClassWithKeyTranform { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition local expectedClassWithKeyTranform_345 +// ^^^^^^^^^^^^^^^^^^^^ reference local ClassWithKeyTranform_154 + myField = "hello" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/myField. + inner { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/inner. + myNestedField = "world" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/myNestedField. + } + } + + new t { +// ^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ + keyTransform = (prop) -> prop.annotations.findOrNull((it) -> it is KeyTransform)?.name +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `tests/deepToTyped.pkl`/keyTransform. +// ^^^^ definition local prop_353 +// ^^^^ reference local prop_353 +// ^^ definition local it_353 +// ^^ reference local it_353 +// ^^^^^^^^^^^^ reference local KeyTransform_150 + }.apply(ClassWithKeyTranform, input) == expectedClassWithKeyTranform +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^^^^^^^^^^^ reference local ClassWithKeyTranform_154 +// ^^^^^ reference local input_338 +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference local expectedClassWithKeyTranform_345 + } + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.net/PklProject b/pkl-pantrysnapshot/pkl.experimental.net/PklProject new file mode 100755 index 00000000..6432e1a9 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.net/PklProject @@ -0,0 +1,24 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Experimental library for handling network (IP and MAC) addresses. + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 PklProject/package. + version = "1.2.1" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.net/net.pkl b/pkl-pantrysnapshot/pkl.experimental.net/net.pkl new file mode 100755 index 00000000..62645ffc --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.net/net.pkl @@ -0,0 +1,1875 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// We sell IP addresses and IP address accessories + /// This module contains types and functions for handling network (IP and MAC) addresses + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/minPklVersion. + module pkl.experimental.net.net +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ + + import "pkl:math" + import "./u128.pkl" + import "./net.pkl" + + // language=RegExp + const hidden hex: String = "[0-9a-fA-F]" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + // language=RegExp + const hidden decByte: String = #"(25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})"# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/decByte. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + // language=RegExp + const hidden ipv4String = #"(\#(decByte)\.){3}\#(decByte)"# +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ipv4String. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/decByte. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/decByte. + + // language=RegExp + const hidden ipv6String = #""" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ipv6String. + (?x: + (\#(hex){1,4}:){7}\#(hex){1,4} # x:x:x:x:x:x:x:x +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | (\#(hex){1,4}:){1,7}: # x:: … x:x:x:x:x:x:x:: +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | (\#(hex){1,4}:){6}:\#(hex){1,4} # x:x:x:x:x:x::x +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | (\#(hex){1,4}:){5}(:\#(hex){1,4}){1,2} # x:x:x:x:x::x … x:x:x:x:x::x:x +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | (\#(hex){1,4}:){4}(:\#(hex){1,4}){1,3} # x:x:x:x::x … x:x:x:x::x:x:x +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | (\#(hex){1,4}:){3}(:\#(hex){1,4}){1,4} # x:x:x::x … x:x:x::x:x:x:x +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | (\#(hex){1,4}:){2}(:\#(hex){1,4}){1,5} # x:x::x … x:x::x:x:x:x:x +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | \#(hex){1,4}:(:\#(hex){1,4}){1,6} # x::x … x::x:x:x:x:x:x +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | :((:\#(hex){1,4}){1,7}|:) # ::x … ::x:x:x:x:x:x:x, :: +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | (?: # IPv6 with trailing IPv4 + (\#(hex){1,4}:){6} # x:x:x:x:x:x: +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | (\#(hex){1,4}:){5}: # x:x:x:x:x:: +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | (\#(hex){1,4}:){4}(:\#(hex){1,4})?: # x:x:x:x:: … x:x:x:x::x: +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | (\#(hex){1,4}:){3}(:\#(hex){1,4}){0,2}: # x:x:x:: … x:x:x::x:x: +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | (\#(hex){1,4}:){2}(:\#(hex){1,4}){0,3}: # x:x:: … x:x::x:x:x: +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | \#(hex){1,4}:(:\#(hex){1,4}){0,4}: # x:: … x::x:x:x:x: +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + | :(:\#(hex){1,4}){0,5}: # :: … ::x:x:x:x:x: +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + )\#(ipv4String) # …d.d.d.d +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ipv4String. + | \#(nonGlobalIPv6String)%[0-9]+ # Scoped address +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/nonGlobalIPv6String. + ) + """# + + // language=RegExp + const hidden nonGlobalIPv6String = #""" +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/nonGlobalIPv6String. + (?xi-U: + ff[0-9a-f][0-9a-d](?: # multicast (FF00::/8 with "scop" less than E (global scope)) + (:[0-9a-f]{1,4}){7} # FFxx:x:x:x:x:x:x:x + | :(:|(:[0-9a-f]{1,4}){1,6}) # FFxx:: … FFxx::x:x:x:x:x:x + | :[0-9a-f]:(:|(:[0-9a-f]{1,4}){1,5}) # FFxx:x:: … FFxx:x::x:x:x:x:x + | (:[0-9a-f]){2}:(:|(:[0-9a-f]{1,4}){1,4}) # FFxx:x:x:: … FFxx:x:x::x:x:x:x + | (:[0-9a-f]){3}:(:|(:[0-9a-f]{1,4}){1,3}) # FFxx:x:x:x:: … FFxx:x:x:x::x:x:x + | (:[0-9a-f]){4}:(:|(:[0-9a-f]{1,4}){1,2}) # FFxx:x:x:x:x:: … FFxx:x:x:x:x::x:x + | (:[0-9a-f]){5}:(:|(:[0-9a-f]{1,4})) # FFxx:x:x:x:x:x:: … FFxx:x:x:x:x:x::x + | (:[0-9a-f]){6}:: # FFxx:x:x:x:x:x:x:: + ) + | fe80(?: # link-local unicast (FE80::/10) + (:0{1,4}){3}(?: # FE80:0:0:0… + :: | :(:[0-9a-f]{1,4}){1,3} # FE80:0:0:0:: … FE80:0:0:0::x:x:x + | :[0-9a-f]{1,4}:(:|(:[0-9a-f]{1,4}){1,2}) # FE80:0:0:0:x:: … FE80:0:0:0:x::x:x + | (:[0-9a-f]{1,4}){2}::([0-9a-f]{1,4})? # FE80:0:0:0:x:x:: … FE80:0:0:0:x:x::x + | (:[0-9a-f]{1,4}){3}:(:|[0-9a-f]{1,4}) # FE80:0:0:0:x:x:x::, FE80:0:0:0:x:x:x:x + ) + | (:0{1,4}){0,2}:(:|(:[0-9a-f]{1,4}){1,4}) # FE80:: … FE80:0:0::x:x:x:x + ) + ) + """# + + /// A string that contains a MAC address + // language=RegExp + typealias MACAddressString = String(matches(Regex(#"(\#(net.hex){1,2}[\.:-]){5}(\#(net.hex){1,2})"#))) +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddressString# +// documentation +// > A string that contains a MAC address +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/hex. + + /// A string that contains either an IPv4 or IPv6 address. + typealias IPAddressString = IPv4AddressString|IPv6AddressString +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPAddressString# +// documentation +// > A string that contains either an IPv4 or IPv6 address. +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + + /// A string that contains either an IPv4 or IPv6 address and port. + typealias IPAddressPortString = IPv4AddressPortString|IPv6AddressPortString +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPAddressPortString# +// documentation +// > A string that contains either an IPv4 or IPv6 address and port. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressPortString# +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + + /// A string that contains either an IPv4 or IPv6 CIDR range. + typealias IPCIDRString = IPv4CIDRString|IPv6CIDRString +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPCIDRString# +// documentation +// > A string that contains either an IPv4 or IPv6 CIDR range. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + + /// An IPv4 or IPv6 address. + typealias IPAddress = IPv4Address|IPv6Address +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPAddress# +// documentation +// > An IPv4 or IPv6 address. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# + + /// An IPv4 or IPv6 network. + typealias IPNetwork = IPv4Network|IPv6Network +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPNetwork# +// documentation +// > An IPv4 or IPv6 network. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network# + + /// A string that contains an IPv4 address. + // language=RegExp + typealias IPv4AddressString = String(matches(Regex(net.ipv4String))) +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# +// documentation +// > A string that contains an IPv4 address. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ipv4String. + + /// A string that contains an IPv6 address. + /// + /// IPv6 unicast and multicast addresses of non-global scope except for the unspecified address and the loopback address + /// may include a scope ID suffix, e.g. `"fe80::1234%1"`. Site-local unicast addresses (`fec0::/10`) are deprecated and + /// thus are considered to be global unicast addresses. + // language=RegExp + typealias IPv6AddressString = String(matches(Regex(net.ipv6String))) +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# +// documentation +// > A string that contains an IPv6 address. +// > +// > IPv6 unicast and multicast addresses of non-global scope except for the unspecified address and the loopback address +// > may include a scope ID suffix, e.g. `"fe80::1234%1"`. Site-local unicast addresses (`fec0::/10`) are deprecated and +// > thus are considered to be global unicast addresses. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ipv6String. + + /// A string that contains an IPv4 address and port. + // language=RegExp + typealias IPv4AddressPortString = String(matches(Regex(#"\#(net.ipv4String):[0-9]{1,5}"#))) +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressPortString# +// documentation +// > A string that contains an IPv4 address and port. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ipv4String. + + /// A string that contains an IPv6 address and port. + // language=RegExp + typealias IPv6AddressPortString = String(matches(Regex(#"\[\#(net.ipv6String)\]:[0-9]{1,5}"#))) +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# +// documentation +// > A string that contains an IPv6 address and port. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ipv6String. + + /// A string that contains an IPv4 address. + // language=RegExp + typealias IPv4CIDRString = String(matches(Regex(#"\#(net.ipv4String)/[0-9]{1,2}"#))) +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# +// documentation +// > A string that contains an IPv4 address. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ipv4String. + + /// A string that contains an IPv6 address. + // language=RegExp + typealias IPv6CIDRString = String(matches(Regex(#"\#(net.ipv6String)/[0-9]{1,3}"#))) +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# +// documentation +// > A string that contains an IPv6 address. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ipv6String. + + /// Creates an [IPAddress] from an [IPAddressString]. + function IP(ip: IPAddressString): IPAddress = +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IP(). +// documentation +// > Creates an [`IPAddress`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L98,C11) from an [`IPAddressString`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L89,C11). +// ^^ definition local ip_132 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPAddressString# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPAddress# + if (ip is IPv6AddressString) IPv6Address(ip) +// ^^ reference local ip_132 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^ reference local ip_132 + else if (ip is IPv4AddressString) IPv4Address(ip) +// ^^ reference local ip_132 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// ^^ reference local ip_132 + else throw("Invalid IP: \(ip)") +// ^^ reference local ip_132 + + /// Creates an [IPv4Address] from an [IPv4AddressString]. + function IPv4Address(ip: IPv4AddressString): IPv4Address = new { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// documentation +// > Creates an [`IPv4Address`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L147,C7) from an [`IPv4AddressString`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L105,C11). +// ^^ definition local ip_138 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# + local parts = ip.split(".") +// ^^^^^ definition local parts_139 +// ^^ reference local ip_138 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). + repr = parts[0].toInt().shl(24) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/repr. +// ^^^^^ reference local parts_139 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). + .or(parts[1].toInt().shl(16)) +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^ reference local parts_139 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). + .or(parts[2].toInt().shl(8)) +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^ reference local parts_139 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). + .or(parts[3].toInt()) +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^ reference local parts_139 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + } + + /// An IPv4 address. + class IPv4Address { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# +// documentation +// > An IPv4 address. + repr: UInt32 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# + + const hidden bitWidth: UInt = 32 +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#bitWidth. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + local self = this +// ^^^^ definition local self_152 + + /// maskHi generates a mask of 1s in the top [prefix] bits of a [UInt32]. + function maskHi(prefix: UInt(isBetween(0, bitWidth))): UInt32 = mask32Hi(prefix) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#maskHi(). +// documentation +// > maskHi generates a mask of 1s in the top [`prefix`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L155,C19) bits of a [`UInt32`](pkl-lsp://stdlib/base.pkl#L956,C11). +// ^^^^^^ definition local prefix_155 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#bitWidth. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Hi(). +// ^^^^^^ reference local prefix_155 + + /// maskLo generates a mask of 1s in the bottom [suffix] bits of a [UInt32]. + function maskLo(suffix: UInt(isBetween(0, bitWidth))): UInt32 = mask32Lo(suffix) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#maskLo(). +// documentation +// > maskLo generates a mask of 1s in the bottom [`suffix`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L158,C19) bits of a [`UInt32`](pkl-lsp://stdlib/base.pkl#L956,C11). +// ^^^^^^ definition local suffix_158 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#bitWidth. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Lo(). +// ^^^^^^ reference local suffix_158 + + /// reverse returns the PTR record name for this address. + function reverse(): String = new IPv4Network { base = self; prefix = self.bitWidth }.reverse() +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#reverse(). +// documentation +// > reverse returns the PTR record name for this address. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#base. +// ^^^^ reference local self_152 +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#prefix. +// ^^^^ reference local self_152 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#bitWidth. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#reverse(). + + /// return the ip address immediately after this one + function next(): IPv4Address = add(1) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#next(). +// documentation +// > return the ip address immediately after this one +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#add(). + + /// return the ip address [n] after this one + function add(n: UInt32): IPv4Address = new { repr = self.repr + n } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#add(). +// documentation +// > return the ip address [`n`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L167,C16) after this one +// ^ definition local n_167 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^^^ reference local self_152 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^ reference local n_167 + + function toString(): IPv4AddressString = new Listing { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#toString(). +// documentation +// > Returns a string representation of `this`. +// > +// > This method is used to convert the values of string interpolation expressions to strings. +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + repr.ushr(24).and(math.maxUInt8).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt8. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + repr.ushr(16).and(math.maxUInt8).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt8. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + repr.ushr(8).and(math.maxUInt8).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt8. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + repr.and(math.maxUInt8).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt8. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + }.join(".") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + } + + // noinspection TypeMismatch + /// Creates an [IPv6Address] from an [IPv6AddressString]. + function IPv6Address(ip: IPv6AddressString): IPv6Address = +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// documentation +// > Creates an [`IPv6Address`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L199,C7) from an [`IPv6AddressString`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L113,C11). +// ^^ definition local ip_179 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# + let (idx = ip.lastIndexOfOrNull("%")) +// ^^^ definition local idx_180 +// ^^ reference local ip_179 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#lastIndexOfOrNull(). + let (scope = idx.ifNonNull((it) -> ip.drop(it+1).toInt())) +// ^^^^^ definition local scope_181 +// ^^^ reference local idx_180 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_181 +// ^^ reference local ip_179 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^ reference local it_181 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + let (ip = idx.ifNonNull((it) -> ip.take(it)) ?? ip) +// ^^ definition local ip_182 +// ^^^ reference local idx_180 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_182 +// ^^ reference local ip_179 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#take(). +// ^^ reference local it_182 +// ^^ reference local ip_179 + let (ipIdx = ip.indexOfOrNull(Regex(":\(ipv4String)$"))) +// ^^^^^ definition local ipIdx_183 +// ^^ reference local ip_182 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#indexOfOrNull(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ipv4String. + let (ipv4 = ipIdx.ifNonNull((_) -> ip.drop(ipIdx+1).split(".").map((s) -> s.toInt()))) +// ^^^^ definition local ipv4_184 +// ^^^^^ reference local ipIdx_183 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ reference local ip_182 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^^^^ reference local ipIdx_183 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local s_184 +// ^ reference local s_184 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + let (ip = ipIdx.ifNonNull((it) -> ip.replaceRange(it, ip.length, ":0:0")) ?? ip) +// ^^ definition local ip_185 +// ^^^^^ reference local ipIdx_183 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_185 +// ^^ reference local ip_182 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceRange(). +// ^^ reference local it_185 +// ^^ reference local ip_182 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^ reference local ip_182 + let (_ip = expandIPv6AddressString(ip).toLowerCase().split(":")) +// ^^^ definition local _ip_186 +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). +// ^^ reference local ip_185 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toLowerCase(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). + new { + repr = u128.UInt128( +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + parseHex32(_ip[0] + _ip[1]), +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/parseHex32(). +// ^^^ reference local _ip_186 +// ^^^ reference local _ip_186 + parseHex32(_ip[2] + _ip[3]), +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/parseHex32(). +// ^^^ reference local _ip_186 +// ^^^ reference local _ip_186 + parseHex32(_ip[4] + _ip[5]), +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/parseHex32(). +// ^^^ reference local _ip_186 +// ^^^ reference local _ip_186 + if (ipv4 != null) ipv4[0].shl(24) + ipv4[1].shl(16) + ipv4[2].shl(8) + ipv4[3] +// ^^^^ reference local ipv4_184 +// ^^^^ reference local ipv4_184 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^^^^ reference local ipv4_184 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^^^^ reference local ipv4_184 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^^^^ reference local ipv4_184 + else parseHex32(_ip[6] + _ip[7]) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/parseHex32(). +// ^^^ reference local _ip_186 +// ^^^ reference local _ip_186 + ) + scopeId = scope +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/scopeId. +// ^^^^^ reference local scope_181 + } + + /// An IPv6 address. + class IPv6Address { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# +// documentation +// > An IPv6 address. + repr: u128.UInt128 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# + + /// The scope ID associated with this address, or [null] if the scope is unknown or not applicable. + /// + /// Only addresses of [non-global scope][isNonGlobalScope] are allowed to have a scope ID. + scopeId: UInt(isNonGlobalScope)? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. +// documentation +// > The scope ID associated with this address, or `null` if the scope is unknown or not applicable. +// > +// > Only addresses of [`non-global scope`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L229,C3) are allowed to have a scope ID. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + + const hidden bitWidth: UInt = 128 +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#bitWidth. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + /// Tells if this address is the unspecified address (`::`). + fixed hidden isUnspecified: Boolean = repr == u128.zero +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isUnspecified. +// documentation +// > Tells if this address is the unspecified address (`::`). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. + + /// Tells if this address is the loopback address (`::1`). + fixed hidden isLoopback: Boolean = repr == u128.one +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isLoopback. +// documentation +// > Tells if this address is the loopback address (`::1`). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. + + /// Tells if this address is an IPv4-mapped address (`::ffff:0:0/96`). + fixed hidden isIPv4Mapped: Boolean = +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Mapped. +// documentation +// > Tells if this address is an IPv4-mapped address (`::ffff:0:0/96`). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + repr.hihi == 0 && repr.hilo == 0 && repr.lohi == 0xffff +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. + + /// Tells if this address is an IPv4-embedded address using the Well-Known Prefix (`64:ff9b::/96`) described by + /// [RFC 6052 §2.1](https://tools.ietf.org/html/rfc6052#section-2.1). + fixed hidden isIPv4Embedded: Boolean = +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Embedded. +// documentation +// > Tells if this address is an IPv4-embedded address using the Well-Known Prefix (`64:ff9b::/96`) described by +// > [RFC 6052 §2.1](https://tools.ietf.org/html/rfc6052#section-2.1). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + repr.hihi == 0x64ff9b && repr.hilo == 0 && repr.lohi == 0 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. + + /// Tells if this address has non-global unicast or multicast scope. + /// + /// Returns [true] for link-local unicast and for multicast with "scop" field less than global. Returns [false] for + /// the [unspecified address][isUnspecified] and the [loopback address][isLoopback], and for site-local addresses as + /// per [RFC 4291 §2.5.7](https://tools.ietf.org/html/rfc4291#section-2.5.7). + fixed hidden isNonGlobalScope: Boolean = +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. +// documentation +// > Tells if this address has non-global unicast or multicast scope. +// > +// > Returns `true` for link-local unicast and for multicast with "scop" field less than global. Returns `false` for +// > the [`unspecified address`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L210,C3) and the [`loopback address`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L213,C3), and for site-local addresses as +// > per [RFC 4291 §2.5.7](https://tools.ietf.org/html/rfc4291#section-2.5.7). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + (repr.hihi == 0xfe800000 && repr.hilo == 0) || +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. + (repr.hihi.ushr(24) == 0xff && repr.hihi.ushr(16).and(0xF) < 0xE) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). + + local self = this +// ^^^^ definition local self_233 + + /// maskHi generates a mask of 1s in the top [prefix] bits of a [u128.UInt128]. + function maskHi(prefix: UInt(isBetween(0, bitWidth))): u128.UInt128 = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#maskHi(). +// documentation +// > maskHi generates a mask of 1s in the top [`prefix`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L236,C19) bits of a [`u128.UInt128`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L37,C7). +// ^^^^^^ definition local prefix_236 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#bitWidth. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# + if (prefix <= 32) u128.UInt128(mask32Hi(prefix), 0, 0, 0) +// ^^^^^^ reference local prefix_236 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Hi(). +// ^^^^^^ reference local prefix_236 + else if (prefix <= 64) u128.UInt128(math.maxUInt32, mask32Hi(prefix - 32), 0, 0) +// ^^^^^^ reference local prefix_236 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Hi(). +// ^^^^^^ reference local prefix_236 + else if (prefix <= 96) u128.UInt128(math.maxUInt32, math.maxUInt32, mask32Hi(prefix - 64), 0) +// ^^^^^^ reference local prefix_236 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Hi(). +// ^^^^^^ reference local prefix_236 + else u128.UInt128(math.maxUInt32, math.maxUInt32, math.maxUInt32, mask32Hi(prefix - 96)) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Hi(). +// ^^^^^^ reference local prefix_236 + + /// maskLo generates a mask of 1s in the bottom [suffix] bits of a [u128.UInt128]. + function maskLo(suffix: UInt(isBetween(0, bitWidth))): u128.UInt128 = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#maskLo(). +// documentation +// > maskLo generates a mask of 1s in the bottom [`suffix`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L243,C19) bits of a [`u128.UInt128`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L37,C7). +// ^^^^^^ definition local suffix_243 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#bitWidth. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# + if (suffix <= 32) u128.UInt128(0, 0, 0, mask32Lo(suffix)) +// ^^^^^^ reference local suffix_243 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Lo(). +// ^^^^^^ reference local suffix_243 + else if (suffix <= 64) u128.UInt128(0, 0, mask32Lo(suffix - 32), math.maxUInt32) +// ^^^^^^ reference local suffix_243 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Lo(). +// ^^^^^^ reference local suffix_243 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + else if (suffix <= 96) u128.UInt128(0, mask32Lo(suffix - 64), math.maxUInt32, math.maxUInt32) +// ^^^^^^ reference local suffix_243 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Lo(). +// ^^^^^^ reference local suffix_243 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + else u128.UInt128(mask32Lo(suffix - 96), math.maxUInt32, math.maxUInt32, math.maxUInt32) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Lo(). +// ^^^^^^ reference local suffix_243 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + + /// reverse returns the PTR record name for this address. + function reverse(): String = new IPv6Network { base = self; prefix = self.bitWidth }.reverse() +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#reverse(). +// documentation +// > reverse returns the PTR record name for this address. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#base. +// ^^^^ reference local self_233 +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#prefix. +// ^^^^ reference local self_233 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#bitWidth. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#reverse(). + + /// return the ip address immediately after this one + function next(): IPv6Address = add(1) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#next(). +// documentation +// > return the ip address immediately after this one +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#add(). + + /// return the ip address [n] after this one + function add(n: UInt32): IPv6Address = (self) { repr = self.repr.add(u128.UInt128(0, 0, 0, n)) } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#add(). +// documentation +// > return the ip address [`n`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L256,C16) after this one +// ^ definition local n_256 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# +// ^^^^ reference local self_233 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference local self_233 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#add(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^ reference local n_256 + + /// Returns the [IPv6Address] in the canonical style described by [RFC 5952](https://tools.ietf.org/html/rfc5952). + /// + /// This includes returning the address in the alternative IPv4-suffixed format if it is [IPv4-mapped][isIPv4Mapped] + /// or [IPv4-embedded][isIPv4Embedded]. + function toString(): IPv6AddressString = _compressIPv6Groups(new Listing { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). +// documentation +// > Returns the [`IPv6Address`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L199,C7) in the canonical style described by [RFC 5952](https://tools.ietf.org/html/rfc5952). +// > +// > This includes returning the address in the alternative IPv4-suffixed format if it is [`IPv4-mapped`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L216,C3) +// > or [`IPv4-embedded`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L221,C3). +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# +// ^^^^^^^^^^^^^^^^^^^ reference local _compressIPv6Groups_470 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + repr.hihi.ushr(16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.hihi.and(math.maxUInt16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt16. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.hilo.ushr(16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.hilo.and(math.maxUInt16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt16. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.lohi.ushr(16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.lohi.and(math.maxUInt16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt16. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + when (isIPv4Mapped || isIPv4Embedded) { +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Mapped. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Embedded. + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + repr.lolo.ushr(24).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + repr.lolo.ushr(16).and(0xFF).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + repr.lolo.ushr(8).and(0xFF).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + repr.lolo.and(0xFF).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + }.join(".") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + } else { + repr.lolo.ushr(16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.lolo.and(math.maxUInt16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt16. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + } + }.join(":")) + (scopeId.ifNonNull((id) -> "%\(id)") ?? "") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local id_280 +// ^^ reference local id_280 + + /// Returns the [IPv6Address] as a string in expanded form. + /// + /// Example: + /// ``` + /// IPv6Address("fe80::1").toExpandedString() == "fe80:0000:0000:0000:0000:0000:0000:0001" + /// ``` + function toExpandedString(): IPv6AddressString = expandIPv6AddressString(new Listing { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toExpandedString(). +// documentation +// > Returns the [`IPv6Address`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L199,C7) as a string in expanded form. +// > +// > Example: +// > ``` +// > IPv6Address("fe80::1").toExpandedString() == "fe80:0000:0000:0000:0000:0000:0000:0001" +// > ``` +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + repr.hihi.ushr(16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.hihi.and(math.maxUInt16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt16. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.hilo.ushr(16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.hilo.and(math.maxUInt16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt16. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.lohi.ushr(16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.lohi.and(math.maxUInt16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt16. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.lolo.ushr(16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + repr.lolo.and(math.maxUInt16).toRadixString(16) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt16. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + }.join(":")) + (scopeId.ifNonNull((id) -> "%\(id)") ?? "") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local id_297 +// ^^ reference local id_297 + } + + /// Creates an [IPNetwork] from an IPv4 or IPv6 CIDR block string + function IPNetwork(cidr: IPCIDRString): IPNetwork = +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPNetwork(). +// documentation +// > Creates an [`IPNetwork`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L101,C11) from an IPv4 or IPv6 CIDR block string +// ^^^^ definition local cidr_301 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPCIDRString# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPNetwork# + if (cidr is IPv4CIDRString) IPv4Network(cidr) +// ^^^^ reference local cidr_301 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network(). +// ^^^^ reference local cidr_301 + else if (cidr is IPv6CIDRString) IPv6Network(cidr) +// ^^^^ reference local cidr_301 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^^ reference local cidr_301 + else throw("Invalid network CIDR: \(cidr)") +// ^^^^ reference local cidr_301 + + /// Creates an [IPv4Network] from an IPv4 CIDR block string + function IPv4Network(cidr: IPv4CIDRString): IPv4Network = new { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network(). +// documentation +// > Creates an [`IPv4Network`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L313,C7) from an IPv4 CIDR block string +// ^^^^ definition local cidr_307 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network# + base = IPv4Address(cidr.split("/").first) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/base. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// ^^^^ reference local cidr_307 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. + prefix = cidr.split("/").last.toInt() +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/prefix. +// ^^^^ reference local cidr_307 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + } + + /// An IPv4 network. + class IPv4Network { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network# +// documentation +// > An IPv4 network. + /// The base address of this network + base: IPv4Address +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# + + /// The CIDR prefix of this network + prefix: UInt(isBetween(0, bitWidth)) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#bitWidth. + + fixed hidden bitWidth = base.bitWidth +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#bitWidth. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#bitWidth. + + const hidden reverseBitResolution: UInt = 8 +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#reverseBitResolution. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + local self = this +// ^^^^ definition local self_324 + + /// The first address in this network. + /// Will be equivalent to [lastAddress] when [prefix] is equal to [bitWidth]. + fixed firstAddress: IPv4Address = new { repr = base.repr.and(base.maskHi(prefix)) } +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#firstAddress. +// documentation +// > The first address in this network. +// > Will be equivalent to [`lastAddress`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L332,C3) when [`prefix`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L318,C3) is equal to [`bitWidth`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L320,C3). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#maskHi(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. + + /// The last address in this network. + /// Will be equivalent to [firstAddress] when [prefix] is equal to [bitWidth]. + fixed lastAddress: IPv4Address = new { repr = base.repr.or(base.maskLo(bitWidth - prefix)) } +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#lastAddress. +// documentation +// > The last address in this network. +// > Will be equivalent to [`firstAddress`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L328,C3) when [`prefix`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L318,C3) is equal to [`bitWidth`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L320,C3). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#maskLo(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#bitWidth. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. + + /// Return the subnet-mask for this network. + function getSubnetMask(): IPv4AddressString = new IPv4Address { repr = base.maskHi(prefix) }.toString() +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#getSubnetMask(). +// documentation +// > Return the subnet-mask for this network. +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#maskHi(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#toString(). + + /// Return true if this network contains [ip]. + function contains(ip: IPv4Address): Boolean = firstAddress.repr <= ip.repr && ip.repr <= lastAddress.repr +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#contains(). +// documentation +// > Return true if this network contains [`ip`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L338,C21). +// ^^ definition local ip_338 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#firstAddress. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^ reference local ip_338 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^ reference local ip_338 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#lastAddress. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. + + /// Generate the name of the reverse DNS zone for this network. + function reverse(): String = base.toString().split(".").take(prefix ~/ reverseBitResolution).reverse().join(".") + ".in-addr.arpa" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#reverse(). +// documentation +// > Generate the name of the reverse DNS zone for this network. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#toString(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#take(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#reverseBitResolution. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#reverse(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + /// Calculate all subnets of this network with prefix [target]. + /// For example, given IPv4Network("10.53.120.0/21").subdivideTo(24), it outputs 8 /24 networks + function subdivideTo(target: UInt(isBetween(0, bitWidth) && this >= prefix)): Listing = +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#subdivideTo(). +// documentation +// > Calculate all subnets of this network with prefix [`target`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L345,C24). +// > For example, given IPv4Network("10.53.120.0/21").subdivideTo(24), it outputs 8 /24 networks +// ^^^^^^ definition local target_345 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#bitWidth. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network# + if (prefix == target) new { self } +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. +// ^^^^^^ reference local target_345 +// ^^^^ reference local self_324 + else new { + ...new IPv4Network { base = self.base; prefix = self.prefix + 1 }.subdivideTo(target) +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^ reference local self_324 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. +// ^^^^ reference local self_324 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#subdivideTo(). +// ^^^^^^ reference local target_345 + ...new IPv4Network { base = new { repr = self.base.repr + 1.shl(bitWidth - self.prefix - 1) }; prefix = self.prefix + 1 }.subdivideTo(target) +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#repr. +// ^^^^ reference local self_324 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#bitWidth. +// ^^^^ reference local self_324 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. +// ^^^^ reference local self_324 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#subdivideTo(). +// ^^^^^^ reference local target_345 + } + + function toString(): String = "\(base.toString())/\(prefix)" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#toString(). +// documentation +// > Returns a string representation of `this`. +// > +// > This method is used to convert the values of string interpolation expressions to strings. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#base. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#toString(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Network#prefix. + } + + /// Produces a listing of IPv4 addresses between [start] and [end], inclusive. + function IPv4Range(start: IPv4Address, end: IPv4Address): Listing = new { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Range(). +// documentation +// > Produces a listing of IPv4 addresses between [`start`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L356,C20) and [`end`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L356,C40), inclusive. +// ^^^^^ definition local start_356 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# +// ^^^ definition local end_356 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address# + for (ipu in IntSeq(start.repr, end.repr)) { +// ^^^ definition local ipu_357 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). +// ^^^^^ reference local start_356 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. +// ^^^ reference local end_356 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. + new { repr = ipu } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/repr. +// ^^^ reference local ipu_357 + } + } + + /// Creates an [IPv6Network] from an IPv6 CIDR block string + function IPv6Network(cidr: IPv6CIDRString): IPv6Network = new { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// documentation +// > Creates an [`IPv6Network`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L369,C7) from an IPv6 CIDR block string +// ^^^^ definition local cidr_363 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network# + base = IPv6Address(cidr.split("/").first) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/base. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^ reference local cidr_363 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. + prefix = cidr.split("/").last.toInt() +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/prefix. +// ^^^^ reference local cidr_363 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + } + + /// An IPv6 network. + class IPv6Network { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network# +// documentation +// > An IPv6 network. + /// The base address of this network + base: IPv6Address +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# + + /// The CIDR prefix of this network + prefix: UInt(isBetween(0, bitWidth)) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#bitWidth. + + fixed hidden bitWidth = base.bitWidth +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#bitWidth. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#bitWidth. + + const hidden reverseBitResolution: UInt = 4 +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#reverseBitResolution. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + + local self = this +// ^^^^ definition local self_380 + + /// The first address in this network. + /// Will be equivalent to [lastAddress] when [prefix] is equal to [bitWidth]. + fixed firstAddress: IPv6Address = (base) { repr = base.repr.and(base.maskHi(prefix)) } +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#firstAddress. +// documentation +// > The first address in this network. +// > Will be equivalent to [`lastAddress`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L388,C3) when [`prefix`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L374,C3) is equal to [`bitWidth`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L376,C3). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#and(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#maskHi(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. + + /// The last address in this network. + /// Will be equivalent to [firstAddress] when [prefix] is equal to [bitWidth]. + fixed lastAddress: IPv6Address = (base) { repr = base.repr.or(base.maskLo(bitWidth - prefix)) } +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#lastAddress. +// documentation +// > The last address in this network. +// > Will be equivalent to [`firstAddress`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L384,C3) when [`prefix`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L374,C3) is equal to [`bitWidth`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L376,C3). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#or(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#maskLo(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#bitWidth. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. + + /// Return true if this network contains [ip]. + /// + /// If both [base.scopeId][IPv6Address.scopeId] and [ip.scopeId][IPv6Address.scopeId] are non-[null], they must match. + /// If either is [null] then scope ID is ignored. + function contains(ip: IPv6Address): Boolean = firstAddress.repr.le(ip.repr) && ip.repr.le(lastAddress.repr) && +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#contains(). +// documentation +// > Return true if this network contains [`ip`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L394,C21). +// > +// > If both [`base.scopeId`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L205,C3) and [`ip.scopeId`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L205,C3) are non-`null`, they must match. +// > If either is `null` then scope ID is ignored. +// ^^ definition local ip_394 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#firstAddress. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#le(). +// ^^ reference local ip_394 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^ reference local ip_394 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#le(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#lastAddress. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. + (base.scopeId == ip.scopeId || base.scopeId == null || ip.scopeId == null) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. +// ^^ reference local ip_394 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. +// ^^ reference local ip_394 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + + /// Generate the name of the reverse DNS zone for this network. + function reverse(): String = (base) { scopeId = null }.toExpandedString().replaceAll(":", "").chars.take(prefix ~/ reverseBitResolution).reverse().join(".") + ".ip6.arpa" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#reverse(). +// documentation +// > Generate the name of the reverse DNS zone for this network. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#scopeId. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toExpandedString(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#chars. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#take(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#reverseBitResolution. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#reverse(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + /// Calculate all subnets of this network with prefix [target]. + /// + /// For example, given `IPv6Network("2620:149:a:960::/61").subdivideTo(64)`, it outputs 8 /64 networks + function subdivideTo(target: UInt(isBetween(0, bitWidth) && this >= prefix)): Listing = +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#subdivideTo(). +// documentation +// > Calculate all subnets of this network with prefix [`target`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L403,C24). +// > +// > For example, given `IPv6Network("2620:149:a:960::/61").subdivideTo(64)`, it outputs 8 /64 networks +// ^^^^^^ definition local target_403 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#bitWidth. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network# + if (prefix == target) new { self } +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. +// ^^^^^^ reference local target_403 +// ^^^^ reference local self_380 + else new { + ...(self) { prefix = self.prefix + 1 }.subdivideTo(target) +// ^^^^ reference local self_380 +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. +// ^^^^ reference local self_380 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#subdivideTo(). +// ^^^^^^ reference local target_403 + ...(self) { base { repr = self.base.repr.add(u128.one.shl(bitWidth - self.prefix - 1)) }; prefix = self.prefix + 1 }.subdivideTo(target) +// ^^^^ reference local self_380 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#repr. +// ^^^^ reference local self_380 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#add(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#bitWidth. +// ^^^^ reference local self_380 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. +// ^^^^ reference local self_380 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#subdivideTo(). +// ^^^^^^ reference local target_403 + } + + function toString(): String = "\(base)/\(prefix)" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#toString(). +// documentation +// > Returns a string representation of `this`. +// > +// > This method is used to convert the values of string interpolation expressions to strings. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#prefix. + } + + /// Produces a listing of IPv6 addresses between [start] and [end], inclusive. + /// + /// If both [start.scopeId][IPv6Address.scopeId] and [end.scopeId][IPv6Address.scopeId] are equal, the resulting + /// addresses will have the same scope ID, otherwise their [scopeId][IPv6Address.scopeId] will be [null]. + function IPv6Range(start: IPv6Address, end: IPv6Address): Listing = new { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Range(). +// documentation +// > Produces a listing of IPv6 addresses between [`start`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L417,C20) and [`end`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L417,C40), inclusive. +// > +// > If both [`start.scopeId`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L205,C3) and [`end.scopeId`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L205,C3) are equal, the resulting +// > addresses will have the same scope ID, otherwise their [`scopeId`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L205,C3) will be `null`. +// ^^^^^ definition local start_417 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# +// ^^^ definition local end_417 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# + local _scopeId = if (start.scopeId == end.scopeId) start.scopeId else null +// ^^^^^^^^ definition local _scopeId_418 +// ^^^^^ reference local start_417 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. +// ^^^ reference local end_417 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. +// ^^^^^ reference local start_417 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + for (ipu in start.repr.seq(end.repr)) { +// ^^^ definition local ipu_419 +// ^^^^^ reference local start_417 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// ^^^ reference local end_417 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. + new { repr = ipu; scopeId = _scopeId } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/repr. +// ^^^ reference local ipu_419 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/scopeId. +// ^^^^^^^^ reference local _scopeId_418 + } + } + + // noinspection TypeMismatch + /// Canonicalizes IPv6 addresses by expanding each component to be 4 digits (zero-padded) and expanding `::` + /// + /// Given input `"123:45:6::7890"`, the output is `"0123:0045:0006:0000:0000:0000:0000:7890"`. + /// + /// If the input is in the alternate form with a trailing IPv4 address, the trailing IPv4 address will be kept intact, + /// although any leading zeroes on the IPv4 components will be dropped. + const function expandIPv6AddressString(_ip: IPv6AddressString): IPv6AddressString = +// ^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). +// documentation +// > Canonicalizes IPv6 addresses by expanding each component to be 4 digits (zero-padded) and expanding `::` +// > +// > Given input `"123:45:6::7890"`, the output is `"0123:0045:0006:0000:0000:0000:0000:7890"`. +// > +// > If the input is in the alternate form with a trailing IPv4 address, the trailing IPv4 address will be kept intact, +// > although any leading zeroes on the IPv4 components will be dropped. +// ^^^ definition local _ip_431 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + let (idx = _ip.lastIndexOfOrNull("%")) +// ^^^ definition local idx_432 +// ^^^ reference local _ip_431 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#lastIndexOfOrNull(). + if ((idx ?? _ip.length) == 39 && !_ip.contains(".")) _ip // assume it's already canonicalized +// ^^^ reference local idx_432 +// ^^^ reference local _ip_431 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^ reference local _ip_431 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). +// ^^^ reference local _ip_431 + else + let (scope = idx.ifNonNull((it) -> _ip.drop(it))) +// ^^^^^ definition local scope_435 +// ^^^ reference local idx_432 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_435 +// ^^^ reference local _ip_431 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^ reference local it_435 + let (ip = idx.ifNonNull((it) -> _ip.take(it)) ?? _ip) +// ^^ definition local ip_436 +// ^^^ reference local idx_432 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_436 +// ^^^ reference local _ip_431 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#take(). +// ^^ reference local it_436 +// ^^^ reference local _ip_431 + let (ipIdx = ip.indexOfOrNull(Regex(":\(ipv4String)$"))) +// ^^^^^ definition local ipIdx_437 +// ^^ reference local ip_436 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#indexOfOrNull(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ipv4String. + let (ipv4 = ipIdx.ifNonNull((it) -> ip.drop(it).replaceAll(Regex("0+(?=[0-9])"), ""))) +// ^^^^ definition local ipv4_438 +// ^^^^^ reference local ipIdx_437 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_438 +// ^^ reference local ip_436 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^ reference local it_438 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + let (ip = ipIdx.ifNonNull((it) -> if (ip[it-1] == ":") ip.take(it+1) else ip.take(it)) ?? ip) +// ^^ definition local ip_439 +// ^^^^^ reference local ipIdx_437 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_439 +// ^^ reference local ip_436 +// ^^ reference local it_439 +// ^^ reference local ip_436 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#take(). +// ^^ reference local it_439 +// ^^ reference local ip_436 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#take(). +// ^^ reference local it_439 +// ^^ reference local ip_436 + let (ip = if (ip.endsWith("::")) ip + "0" else ip) +// ^^ definition local ip_440 +// ^^ reference local ip_439 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#endsWith(). +// ^^ reference local ip_439 +// ^^ reference local ip_439 + let (groupCount = if (ipv4 == null) 8 else 6) +// ^^^^^^^^^^ definition local groupCount_441 +// ^^^^ reference local ipv4_438 + let (stuff = ip.split("::").map((half) -> half.split(":").map((octet) -> octet.padStart(4, "0")))) +// ^^^^^ definition local stuff_442 +// ^^ reference local ip_440 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^ definition local half_442 +// ^^^^ reference local half_442 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^^ definition local octet_442 +// ^^^^^ reference local octet_442 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + (if (stuff.length == 1) stuff.first.join(":") +// ^^^^^ reference local stuff_442 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^ reference local stuff_442 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + else if (stuff.length == 2) (stuff.first + List("0000").repeat(groupCount - stuff.first.length - stuff.last.length) + stuff.last).join(":") +// ^^^^^ reference local stuff_442 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^ reference local stuff_442 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#repeat(). +// ^^^^^^^^^^ reference local groupCount_441 +// ^^^^^ reference local stuff_442 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^ reference local stuff_442 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^ reference local stuff_442 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + else throw("unintelligible IPv6 address: " + _ip)) +// ^^^ reference local _ip_431 + + (ipv4 ?? "") + (scope ?? "") +// ^^^^ reference local ipv4_438 +// ^^^^^ reference local scope_435 + + // noinspection TypeMismatch + /// Compresses IPv6 addresses by stripping leading zeros from each component and collapsing repeated zero components to `::`. + /// + /// Given input `"0123:0045:0006:0000:0000:0000:0000:7890"`, the output is `"123:45:6::7890"`. + /// + /// If there are multiple possible spans of zeroes to collapse, the longest span is chosen. If there are multiple + /// candidates for longest span, the first such span is chosen. The output is consistent with + /// [RFC5952 §4.2.3](https://datatracker.ietf.org/doc/html/rfc5952#section-4.2.3). + const function compressIPv6AddressString(ip: IPv6AddressString): IPv6AddressString = +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). +// documentation +// > Compresses IPv6 addresses by stripping leading zeros from each component and collapsing repeated zero components to `::`. +// > +// > Given input `"0123:0045:0006:0000:0000:0000:0000:7890"`, the output is `"123:45:6::7890"`. +// > +// > If there are multiple possible spans of zeroes to collapse, the longest span is chosen. If there are multiple +// > candidates for longest span, the first such span is chosen. The output is consistent with +// > [RFC5952 §4.2.3](https://datatracker.ietf.org/doc/html/rfc5952#section-4.2.3). +// ^^ definition local ip_456 +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + let (ip = expandIPv6AddressString(ip).toLowerCase()) +// ^^ definition local ip_457 +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). +// ^^ reference local ip_456 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toLowerCase(). + let (idx = ip.lastIndexOfOrNull("%")) +// ^^^ definition local idx_458 +// ^^ reference local ip_457 +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#lastIndexOfOrNull(). + let (scope = idx.ifNonNull((it) -> ip.drop(it).replaceFirst(Regex("^%0+(?=[0-9])"), "%"))) +// ^^^^^ definition local scope_459 +// ^^^ reference local idx_458 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_459 +// ^^ reference local ip_457 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^ reference local it_459 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + let (ip = idx.ifNonNull((it) -> ip.take(it)) ?? ip) +// ^^ definition local ip_460 +// ^^^ reference local idx_458 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_460 +// ^^ reference local ip_457 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#take(). +// ^^ reference local it_460 +// ^^ reference local ip_457 + let (trimmed = ip.split(":").map((octet) -> +// ^^^^^^^ definition local trimmed_461 +// ^^ reference local ip_460 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^^ definition local octet_461 + if (octet == "0000") "0" +// ^^^^^ reference local octet_461 + else if (octet.contains(".")) octet // must be a trailing IPv4 address +// ^^^^^ reference local octet_461 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). +// ^^^^^ reference local octet_461 + else octet.dropWhile((c) -> c == "0") +// ^^^^^ reference local octet_461 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#dropWhile(). +// ^ definition local c_464 +// ^ reference local c_464 + ).join(":")) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + _compressIPv6Groups(trimmed) + (scope ?? "") +// ^^^^^^^^^^^^^^^^^^^ reference local _compressIPv6Groups_470 +// ^^^^^^^ reference local trimmed_461 +// ^^^^^ reference local scope_459 + + // Performs only the portion of IPv6 address canonicalization that is replacing the longest sequence of zeroes + // with `::`. + local const function _compressIPv6Groups(ip: String): IPv6AddressString = +// ^^^^^^^^^^^^^^^^^^^ definition local _compressIPv6Groups_470 +// ^^ definition local ip_470 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + let (match = Regex(#"(?<=:|^)(?:0:)+0(?=:|$)"#).findMatchesIn(ip).maxByOrNull((it) -> it.value.length)) +// ^^^^^ definition local match_471 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex#findMatchesIn(). +// ^^ reference local ip_470 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#maxByOrNull(). +// ^^ definition local it_471 +// ^^ reference local it_471 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + if (match == null) ip // no groups to replace with :: +// ^^^^^ reference local match_471 +// ^^ reference local ip_470 + else if (match.start == 0 && match.end == ip.length) "::" +// ^^^^^ reference local match_471 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. +// ^^^^^ reference local match_471 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#end. +// ^^ reference local ip_470 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + else if (match.start == 0 || match.end == ip.length) ip.replaceRange(match.start, match.end, ":") +// ^^^^^ reference local match_471 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. +// ^^^^^ reference local match_471 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#end. +// ^^ reference local ip_470 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^ reference local ip_470 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceRange(). +// ^^^^^ reference local match_471 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. +// ^^^^^ reference local match_471 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#end. + else ip.replaceRange(match.start, match.end, "") +// ^^ reference local ip_470 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceRange(). +// ^^^^^ reference local match_471 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. +// ^^^^^ reference local match_471 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#end. + + function MACAddress(mac: MACAddressString): MACAddress = new { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress(). +// ^^^ definition local mac_477 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddressString# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress# + repr = mac.split(Regex("[.:-]")).map((octet) -> parseHexOctet(octet)) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/repr. +// ^^^ reference local mac_477 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^^ definition local octet_478 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/parseHexOctet(). +// ^^^^^ reference local octet_478 + } + + class MACAddress { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress# + hidden repr: List(length == 6) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#repr. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. + + local self = this +// ^^^^ definition local self_484 + + function toString(): MACAddressString = repr.map((octet) -> octet.toRadixString(16).padStart(2, "0")).join(":") +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#toString(). +// documentation +// > Returns a string representation of `this`. +// > +// > This method is used to convert the values of string interpolation expressions to strings. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddressString# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#repr. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^^ definition local octet_486 +// ^^^^^ reference local octet_486 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + function eui64(addr: IPv6Address): IPv6Address = new { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#eui64(). +// ^^^^ definition local addr_488 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address# + repr = u128.UInt128( +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + addr.repr.hihi, +// ^^^^ reference local addr_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. + addr.repr.hilo, +// ^^^^ reference local addr_488 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. + uint32FromBytes(self.repr[0].xor(0x02), self.repr[1], self.repr[2], 0xff), +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/uint32FromBytes(). +// ^^^^ reference local self_484 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#repr. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#xor(). +// ^^^^ reference local self_484 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#repr. +// ^^^^ reference local self_484 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#repr. + uint32FromBytes(0xfe, self.repr[3], self.repr[4], self.repr[5]) +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/uint32FromBytes(). +// ^^^^ reference local self_484 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#repr. +// ^^^^ reference local self_484 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#repr. +// ^^^^ reference local self_484 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#repr. + ) + } + } + + /// parseHex tranforms a single hexadecimal character into its unsigned integer representation. + function parseHex(digit: Char): UInt8 = +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/parseHex(). +// documentation +// > parseHex tranforms a single hexadecimal character into its unsigned integer representation. +// ^^^^^ definition local digit_499 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Char# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# + let (d = digit.toLowerCase()) +// ^ definition local d_500 +// ^^^^^ reference local digit_499 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toLowerCase(). + "0123456789abcdef".chars.findIndexOrNull((it) -> it == d) ?? +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#chars. +// ^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#findIndexOrNull(). +// ^^ definition local it_501 +// ^^ reference local it_501 +// ^ reference local d_500 + throw("Unrecognized hex digit: \(d)") +// ^ reference local d_500 + + /// parseHexOctet tranforms a two hexadecimal characters into its unsigned integer representation. + function parseHexOctet(octet: String(length == 2)): UInt8 = byteLut[octet.toLowerCase()] +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/parseHexOctet(). +// documentation +// > parseHexOctet tranforms a two hexadecimal characters into its unsigned integer representation. +// ^^^^^ definition local octet_505 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# +// ^^^^^^^ reference local byteLut_514 +// ^^^^^ reference local octet_505 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toLowerCase(). + + /// parseHex32 transforms an 8 character hexidecimal string into its UInt32 representation. + function parseHex32(s: String(length == 8)): UInt32 = +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/parseHex32(). +// documentation +// > parseHex32 transforms an 8 character hexidecimal string into its UInt32 representation. +// ^ definition local s_508 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# + IntSeq(0, 7) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). + .step(2) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq#step(). + .map((it) -> s.substring(it, it + 2)) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq#map(). +// ^^ definition local it_511 +// ^ reference local s_508 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^ reference local it_511 +// ^^ reference local it_511 + .fold(0, (acc, it) -> acc.shl(8) + parseHexOctet(it)) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^ definition local acc_512 +// ^^ definition local it_512 +// ^^^ reference local acc_512 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/parseHexOctet(). +// ^^ reference local it_512 + + /// byteLut is a lookup table mapping a string of two lowercase hex digits (zero-padded) to the UInt8 value. + const local byteLut = IntSeq(0, 255).map((it) -> it).toMap((it) -> it.toRadixString(16).padStart(2, "0"), (it) -> it) +// ^^^^^^^ definition local byteLut_514 +// documentation +// > byteLut is a lookup table mapping a string of two lowercase hex digits (zero-padded) to the UInt8 value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq#map(). +// ^^ definition local it_515 +// ^^ reference local it_515 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toMap(). +// ^^ definition local it_515 +// ^^ reference local it_515 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). +// ^^ definition local it_515 +// ^^ reference local it_515 + + /// mask32Hi generates a mask of 1s in the top [prefix] bits of a [UInt32]. + const function mask32Hi(prefix: UInt(isBetween(0, 32))): UInt32 = math.maxUInt32.ushr(32-prefix).shl(32-prefix) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Hi(). +// documentation +// > mask32Hi generates a mask of 1s in the top [`prefix`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L518,C25) bits of a [`UInt32`](pkl-lsp://stdlib/base.pkl#L956,C11). +// ^^^^^^ definition local prefix_518 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^^^ reference local prefix_518 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^^^^^^ reference local prefix_518 + /// mask32Lo generates a mask of 1s in the bottom [suffix] bits of a [UInt32]. + const function mask32Lo(suffix: UInt(isBetween(0, 32))): UInt32 = math.maxUInt32.ushr(32-suffix) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/mask32Lo(). +// documentation +// > mask32Lo generates a mask of 1s in the bottom [`suffix`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/net.pkl#L520,C25) bits of a [`UInt32`](pkl-lsp://stdlib/base.pkl#L956,C11). +// ^^^^^^ definition local suffix_520 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^^^^^^ reference local suffix_520 + + /// uint32FromBytes constructs a [UInt32] from four [UInt8] values. + const function uint32FromBytes(hihi: UInt8, hilo: UInt8, lohi: UInt8, lolo: UInt8): UInt32 = +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/uint32FromBytes(). +// documentation +// > uint32FromBytes constructs a [`UInt32`](pkl-lsp://stdlib/base.pkl#L956,C11) from four [`UInt8`](pkl-lsp://stdlib/base.pkl#L950,C11) values. +// ^^^^ definition local hihi_523 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# +// ^^^^ definition local hilo_523 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# +// ^^^^ definition local lohi_523 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# +// ^^^^ definition local lolo_523 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# + hihi.shl(24).or(hilo.shl(16)).or(lohi.shl(8)).or(lolo) +// ^^^^ reference local hihi_523 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^ reference local hilo_523 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^ reference local lohi_523 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^ reference local lolo_523 + diff --git a/pkl-pantrysnapshot/pkl.experimental.net/tests/net.pkl b/pkl-pantrysnapshot/pkl.experimental.net/tests/net.pkl new file mode 100755 index 00000000..ed819eeb --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.net/tests/net.pkl @@ -0,0 +1,1353 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.net.tests.net +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/net.pkl`/ + + amends "pkl:test" + + import "../net.pkl" + import "../u128.pkl" + + local baseIP = net.IPv6Address("::") +// ^^^^^^ definition local baseIP_23 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/net.pkl`/facts. + ["MACAddress"] { + net.MACAddress("34:73:5A:FA:AF:22").eui64(baseIP).toExpandedString() == "0000:0000:0000:0000:3673:5aff:fefa:af22" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/MACAddress#eui64(). +// ^^^^^^ reference local baseIP_23 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toExpandedString(). + } + // note: IPv4Address() and IPv6Address() must be invoked prior to any tests that reference the IPv[46]AddressString + // typealiases. This works around a pkl 0.25 bug that otherwise causes java exceptions. + ["IPv4Address =="] { + net.IPv4Address("127.0.0.1") != net.IPv4Address("127.0.0.2") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). + net.IPv4Address("127.0.0.1") != net.IPv4Address("127.0.1.1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). + net.IPv4Address("127.0.0.1") != net.IPv4Address("127.1.0.1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). + net.IPv4Address("127.0.0.1") != net.IPv4Address("128.0.0.1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). + } + ["IPv6Address =="] { + net.IPv6Address("fe80::1") == net.IPv6Address("fe80::1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1") != net.IPv6Address("fe80::2") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1") != net.IPv6Address("fe80::1:1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1") != net.IPv6Address("fe80::1:0:1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1") != net.IPv6Address("fe80::1:0:0:1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1") != net.IPv6Address("fe80:0:0:1::1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1") != net.IPv6Address("fe80:0:1::1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1") != net.IPv6Address("fe80:1::1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1") != net.IPv6Address("fe81::1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1%1") == net.IPv6Address("fe80::1%1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1%1") != net.IPv6Address("fe80::1%2") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1%1") != net.IPv6Address("fe80::1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1%0") != net.IPv6Address("fe80::1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + } + // similarly IPv6Network() must be invoked prior to using IPv6CIDRString + ["IPv6Network =="] { + net.IPv6Network("2001:db8::/96") == net.IPv6Network("2001:db8::/96") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). + net.IPv6Network("2001:db8::/96") != net.IPv6Network("2001:db8::/48") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). + net.IPv6Network("2001:db8::/96") != net.IPv6Network("2001:db8::1/96") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). + } + ["IPv4AddressString"] { + "0.0.0.0" is net.IPv4AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + "127.0.0.1" is net.IPv4AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + "1.1.1.1" is net.IPv4AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + "000.000.000.000" is net.IPv4AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + "255.255.255.255" is net.IPv4AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("0000.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("256.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("260.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("300.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("1.1.1" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("1.1.1." is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("1.1.1.1." is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("1.a.1.1" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("1..1.1" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("1..1.1.1" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !(".1.1.1" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !(".1.1.1.1" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + } + ["IPv6AddressString (pure IPv6)"] { + "0:0:0:0:0:0:0:0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3:4:5:6:7:8" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "ffff::" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::1" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::1:2:3:4:5:6:7" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1::" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3:4:5:6:7::" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::1" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::1:2:3:4:5:6:7" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3:4:5:6::7" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3:4:5::6:7" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3:4::5:6:7" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3::4:5:6:7" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2::3:4:5:6:7" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1::2:3:4:5:6:7" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3:4:5::6" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3:4::5" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3::4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2::3" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1::2" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1:2:3:4:5:6:7:8:9" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1:2:3:4:5:6:7:" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1:2:3:4:5:6:7:8:" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !(":1:2:3:4:5:6:7" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !(":1:2:3:4:5:6:7:8" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::1:2:3:4:5:6:7:8" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1:2:3:4:5:6:7:8::" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1::2::" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::1::2" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1::g" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1:::2" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("FFFFF::" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + } + ["IPv6AddressString (IPv4-compatible)"] { + "::0.0.0.0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::000.000.000.000" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::255.255.255.255" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::256.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::260.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::300.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::0000.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::a.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::0.0.0." is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::0.0.0.0." is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::0.0.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + } + ["IPv6AddressString (IPv4-mapped)"] { + "::ffff:0.0.0.0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::ffff:000.000.000.000" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::ffff:255.255.255.255" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:256.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:260.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:300.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0000.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:a.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0.0.0." is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0.0.0.0." is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0.0.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + } + ["IPv6AddressString (IPv4-translated)"] { + "::ffff:0:0.0.0.0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::ffff:0000:0.0.0.0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::ffff:0:255.255.255.255" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::ffff:0:000.000.000.000" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0:256.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0:260.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0:300.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0:0000.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0:a.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0:0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0:0.0.0." is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0:0.0.0.0." is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:0:0.0.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + } + ["IPv6AddressString (IPv4-embedded)"] { + "64:ff9b::0.0.0.0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "0::0.0.0.0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "0:0:0:0::0.0.0.0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "ffff:ffff:ffff:ffff::255.255.255.255" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "64:ff9b::255.255.255.255" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "64:ff9b::000.000.000.000" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("64:ff9b::256.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("64:ff9b::260.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("64:ff9b::300.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("64:ff9b::0000.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("64:ff9b::a.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("64:ff9b::0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("64:ff9b::0.0.0." is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("64:ff9b::0.0.0.0." is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("64:ff9b::0.0.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + } + ["IPv6AddressString (miscellaneous IPv4)"] { + "0:0:0:0:0:0:0.0.0.0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3:4:5:6:1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:255.255.255.255" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::1:1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::1:2:3:4:5:1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1::1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3:4:5::1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3:4::5:1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3::4:5:1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2::3:4:5:1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1::2:3:4:5:1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2:3::4:1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1:2::3:1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "1::2:1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::1.2.3.4" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "::0.0.0.0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1:2:3:4:5:6:7:1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1:2:3:4:5:6:1.2.3" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1:2:3:4:5:6:1.2.3.4.5" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1:2:3:4:5:6::1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !(":1:2:3:4:5:1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !(":1:2:3:4:5:6:1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::1:2:3:4:5:6:1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1::2::1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1::2::3:1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::1::2:1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::1::1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1:::2:1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("FFFFF::1.2.3.4" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("1.2.3.4::" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + } + ["Scoped IPv6AddressString (link-local unicast)"] { + "fe80::%1" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "FE80::%1" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "fe80::%999" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "fe80:0:0:0:0:0:0:0%1" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "fe80:0:0:0:a:b:c:d%2" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "fe80::aaaa%0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "fe80:0:0:0:1::%1" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "fe80:0:0::1%2" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe80:1::%0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe80::a:b:c:d:e%0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe81::%1" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("febf::%1" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe80::%" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe80::%a" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe80::%eth0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe80:0:0:1::%1" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe80::%-1" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe80::% 1" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe80::%%1" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe80::%1%1" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + } + ["Scoped IPv6AddressString (multicast)"] { + "ff00::%1" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "FF00::%1" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "ff0d::%1" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "ff1d::%1" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "fffd::%1" is net.IPv6AddressString // we don't restrict flags, for future compatibility reasons +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "ff00::%999" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "ff0d:0:0:0:0:0:0:0%0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "ff00::7:8%0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + "ff00:2:3:4::8%0" is net.IPv6AddressString +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("ff0e::%1" is net.IPv6AddressString) // global scope +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fffe::%1" is net.IPv6AddressString) // global scope +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("FF0E::%1" is net.IPv6AddressString) // global scope +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("ff00::%-1" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("ff00::% 1" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("ff00::%" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("ff00::%a" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("ff00::%eth0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("ff00::%1%1" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("ff00:1:2:3:4:5:6:7:8%1" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + } + ["Global IPv6AddressString can't be scoped"] { + !("::%0" is net.IPv6AddressString) // technically this is implementation-defined, we don't support it +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::1%0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("0:0:0:0:0:0:0:0%0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("a:b:c:d:1:2:3:4%0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fec0::%1" is net.IPv6AddressString) // site-local unicast is deprecated, considered global now +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::1.2.3.4%0" is net.IPv6AddressString) // IPv6+IPv4 syntax implies global scope +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::ffff:1.2.3.4%0" is net.IPv6AddressString) // IPv4-mapped can be scoped in some implementations, but not ours +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("0:fe80::%0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::fe80%0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fdff::%0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + } + ["IPv4CIDRString"] { + "0.0.0.0/1" is net.IPv4CIDRString +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# + "255.255.255.255/32" is net.IPv4CIDRString +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# + !("0.0.0.0/" is net.IPv4CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# + !("0.0.0.0/100" is net.IPv4CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# + !("0.0.0.0/a" is net.IPv4CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# + !("/10" is net.IPv4CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# + !("" is net.IPv4CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# + } + ["IPv6CIDRString"] { + "fe80::/10" is net.IPv6CIDRString +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + "::1/128" is net.IPv6CIDRString +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + "::1.2.3.4/96" is net.IPv6CIDRString +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + "fe80::%2/10" is net.IPv6CIDRString +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + !("fe80::/" is net.IPv6CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + !("fe80::/1000" is net.IPv6CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + !("fe80::/a" is net.IPv6CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + !("/10" is net.IPv6CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + !("" is net.IPv6CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + !("0.0.0.0/10" is net.IPv6CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + } + ["IPv4AddressPortString"] { + "0.0.0.0:0" is net.IPv4AddressPortString +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressPortString# + "255.255.255.255:65535" is net.IPv4AddressPortString +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressPortString# + !("0.0.0.0:" is net.IPv4AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressPortString# + !("0.0.0.0:123456" is net.IPv4AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressPortString# + !(":1" is net.IPv4AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressPortString# + !("" is net.IPv4AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressPortString# + !("0.0.0.0:a" is net.IPv4AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressPortString# + !("[0.0.0.0]:1" is net.IPv4AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressPortString# + } + ["IPv6AddressPortString"] { + "[::1]:80" is net.IPv6AddressPortString +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + "[::]:1" is net.IPv6AddressPortString +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + "[fe80::]:65535" is net.IPv6AddressPortString +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + "[fe80::%2]:65535" is net.IPv6AddressPortString +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + !("[::1]:" is net.IPv6AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + !("[::1]:123456" is net.IPv6AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + !(":1" is net.IPv6AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + !("" is net.IPv6AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + !("[::1]:a" is net.IPv6AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + !("0.0.0.0:1" is net.IPv6AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + !("[0.0.0.0]:1" is net.IPv6AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + !("::1:10" is net.IPv6AddressPortString) +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressPortString# + } + ["IPv4Address()"] { + net.IPv4Address("127.0.0.1").repr == 0x7F000001 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. + net.IPv4Address("0.0.0.0").repr == 0 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. + net.IPv4Address("255.255.255.255").repr == 0xFFFFFFFF +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. + net.IPv4Address("126.127.128.129").repr == 0x7E7F8081 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. + net.IPv4Address("172.16.254.1").repr == 0xAC10FE01 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4Address#repr. + } + ["IPv6Address()"] { + net.IPv6Address("fe80::1").repr == u128.UInt128(0xFE800000, 0, 0, 1) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + net.IPv6Address("1:10:100:1000:ff00:0ff0:00ff:f00f").repr == u128.UInt128(0x10010, 0x1001000, 0xff000ff0, 0xfff00f) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + net.IPv6Address("::a:b").repr == u128.UInt128(0, 0, 0, 0xa000b) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + net.IPv6Address("2001::").repr == u128.UInt128(0x20010000, 0, 0, 0) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + net.IPv6Address("::ffff:129.144.52.38").repr == u128.UInt128(0, 0, 0xffff, 0x81903426) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + net.IPv6Address("fe80::127.0.0.1").repr == u128.UInt128(0xfe800000, 0, 0, 0x7f000001) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#repr. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + } + ["IPv6Address() scopeId"] { + net.IPv6Address("fe80::1").scopeId == null +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Address("fe80::127.0.0.1").scopeId == null +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Address("fe80:3::1ff:fe23:4567:890a").scopeId == null // non-standard alternative we don't support +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Address("fe80::1%1").scopeId == 1 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Address("ff00::%2").scopeId == 2 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Address("fe80::%123").scopeId == 123 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Address("fe80::%0").scopeId == 0 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + // check that manually-constructed addresses respect restrictions on scopeId + let (ip = net.IPv6Address("::")) module.catch(() -> (ip) { scopeId = 1 }.scopeId ) != null +// ^^ definition local ip_332 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^ reference local ip_332 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/net.pkl`/scopeId. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + let (ip = net.IPv6Address("::1")) module.catch(() -> (ip) { scopeId = 1 }.scopeId ) != null +// ^^ definition local ip_333 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^ reference local ip_333 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/net.pkl`/scopeId. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + let (ip = net.IPv6Address("fec0::")) module.catch(() -> (ip) { scopeId = 1 }.scopeId ) != null +// ^^ definition local ip_334 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^ reference local ip_334 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/net.pkl`/scopeId. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + let (ip = net.IPv6Address("2001:db8::")) module.catch(() -> (ip) { scopeId = 1 }.scopeId ) != null +// ^^ definition local ip_335 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^ reference local ip_335 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/net.pkl`/scopeId. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + let (ip = net.IPv6Address("ff0e::")) module.catch(() -> (ip) { scopeId = 1 }.scopeId ) != null +// ^^ definition local ip_336 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^ reference local ip_336 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/net.pkl`/scopeId. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + let (ip = net.IPv6Address("ff0f::")) module.catch(() -> (ip) { scopeId = 1 }.scopeId ) != null +// ^^ definition local ip_337 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^ reference local ip_337 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/net.pkl`/scopeId. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + let (ip = net.IPv6Address("fe7f::")) module.catch(() -> (ip) { scopeId = 1 }.scopeId ) != null +// ^^ definition local ip_338 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^ reference local ip_338 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/net.pkl`/scopeId. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + let (ip = net.IPv6Address("fe80:0:0:1::")) module.catch(() -> (ip) { scopeId = 1 }.scopeId ) != null +// ^^ definition local ip_339 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^ reference local ip_339 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/net.pkl`/scopeId. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + } + ["IPv6Address methods work with scopeId"] { + net.IPv6Address("fe80::%1").next() == net.IPv6Address("fe80::1%1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#next(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Address("fe80::1:2%1").reverse() == net.IPv6Address("fe80::1:2").reverse() // scopeId gets ignored here +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#reverse(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#reverse(). + } + ["IPv6Address.isUnspecified"] { + net.IPv6Address("::").isUnspecified +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isUnspecified. + !net.IPv6Address("::1").isUnspecified +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isUnspecified. + !net.IPv6Address("1::").isUnspecified +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isUnspecified. + } + ["IPv6Address.isLoopback"] { + net.IPv6Address("::1").isLoopback +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isLoopback. + !net.IPv6Address("::").isLoopback +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isLoopback. + !net.IPv6Address("1::").isLoopback +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isLoopback. + !net.IPv6Address("::127.0.0.1").isLoopback +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isLoopback. + !net.IPv6Address("::ffff:127.0.0.1").isLoopback +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isLoopback. + !net.IPv6Address("::ffff:0:127.0.0.1").isLoopback +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isLoopback. + !net.IPv6Address("64:ff9b::127.0.0.1").isLoopback +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isLoopback. + } + ["IPv6Address.isIPv4Mapped"] { + net.IPv6Address("::ffff:192.168.1.1").isIPv4Mapped +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Mapped. + net.IPv6Address("::ffff:0.0.0.0").isIPv4Mapped +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Mapped. + net.IPv6Address("::ffff:255.255.255.255").isIPv4Mapped +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Mapped. + !net.IPv6Address("::192.168.1.1").isIPv4Mapped +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Mapped. + !net.IPv6Address("::ffff:0:192.168.1.1").isIPv4Mapped +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Mapped. + !net.IPv6Address("::ffff:255.255.255.255").next().isIPv4Mapped +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#next(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Mapped. + !net.IPv6Address("::fffe:255.255.255.255").isIPv4Mapped +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Mapped. + !net.IPv6Address("64:ff9b::192.168.1.1").isIPv4Mapped +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Mapped. + } + ["IPv6Address.isIPv4Embedded"] { + net.IPv6Address("64:ff9b::192.168.1.1").isIPv4Embedded +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Embedded. + net.IPv6Address("64:ff9b::0.0.0.0").isIPv4Embedded +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Embedded. + net.IPv6Address("64:ff9b::255.255.255.255").isIPv4Embedded +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Embedded. + !net.IPv6Address("64:ff9b::255.255.255.255").next().isIPv4Embedded +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#next(). +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Embedded. + !net.IPv6Address("64:ff9a::255.255.255.255").isIPv4Embedded +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Embedded. + !net.IPv6Address("::ffff:192.168.1.1").isIPv4Embedded +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Embedded. + !net.IPv6Address("0:64:ff9b::192.168.1.1").isIPv4Embedded +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isIPv4Embedded. + } + ["IPv6Address.isNonGlobalScope"] { + // link-local unicast + net.IPv6Address("fe80::").isNonGlobalScope +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + net.IPv6Address("fe80::ffff:ffff:ffff:ffff").isNonGlobalScope +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + net.IPv6Address("fe80:0:0:0:1::").isNonGlobalScope +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + !net.IPv6Address("fe80:0:0:1::").isNonGlobalScope +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + !net.IPv6Address("fe81::").isNonGlobalScope +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + // multicast + net.IPv6Address("ff00::").isNonGlobalScope +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + net.IPv6Address("ff10::").isNonGlobalScope +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + net.IPv6Address("fffd::").isNonGlobalScope +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + !net.IPv6Address("ff0e::").isNonGlobalScope // scop=e +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + !net.IPv6Address("ff0f::").isNonGlobalScope // scop>e +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + !net.IPv6Address("fe00::").isNonGlobalScope +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + // addresses that don't count + !net.IPv6Address("::").isNonGlobalScope +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + !net.IPv6Address("::1").isNonGlobalScope +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + !net.IPv6Address("fec0::").isNonGlobalScope // site-local, deprecated +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#isNonGlobalScope. + } + ["IPv6Network.contains() and scopeId"] { + net.IPv6Network("fe80::%1/96").contains(net.IPv6Address("fe80::1")) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#contains(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Network("fe80::%1/96").contains(net.IPv6Address("fe80::1%1")) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#contains(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + net.IPv6Network("fe80::/96").contains(net.IPv6Address("fe80::1%1")) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#contains(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + !net.IPv6Network("fe80::%1/96").contains(net.IPv6Address("fe80::1%2")) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#contains(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). + } + ["IPv6Network.subdivideTo() preserves scopeId"] { + net.IPv6Network("fe80::%1/64").subdivideTo(67).toList().every((it) -> it.base.scopeId == 1) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#subdivideTo(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^ definition local it_404 +// ^^ reference local it_404 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Network("fe80::/64").subdivideTo(67).toList().every((it) -> it.base.scopeId == null) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#subdivideTo(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^ definition local it_405 +// ^^ reference local it_405 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#base. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + } + ["IPv6Network first/last address preserves scopeId"] { + net.IPv6Network("fe80::%1/64").firstAddress.scopeId == 1 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#firstAddress. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Network("fe80::%1/64").lastAddress.scopeId == 1 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#lastAddress. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Network("fe80::/64").firstAddress.scopeId == null +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#firstAddress. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Network("fe80::/64").lastAddress.scopeId == null +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Network#lastAddress. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + } + ["IPv6Range() preserves scopeId as appropriate"] { + net.IPv6Range(net.IPv6Address("fe80::%1"), net.IPv6Address("fe80::10%1")).toList().every((ip) -> ip.scopeId == 1) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Range(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^ definition local ip_414 +// ^^ reference local ip_414 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Range(net.IPv6Address("fe80::%1"), net.IPv6Address("fe80::10%2")).toList().every((ip) -> ip.scopeId == null) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Range(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^ definition local ip_415 +// ^^ reference local ip_415 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Range(net.IPv6Address("fe80::"), net.IPv6Address("fe80::10%1")).toList().every((ip) -> ip.scopeId == null) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Range(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^ definition local ip_416 +// ^^ reference local ip_416 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Range(net.IPv6Address("fe80::%1"), net.IPv6Address("fe80::10")).toList().every((ip) -> ip.scopeId == null) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Range(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^ definition local ip_417 +// ^^ reference local ip_417 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + net.IPv6Range(net.IPv6Address("fe80::"), net.IPv6Address("fe80::10")).toList().every((ip) -> ip.scopeId == null) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Range(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^ definition local ip_418 +// ^^ reference local ip_418 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#scopeId. + } + ["IPv4AddressString can't contain unicode digits"] { + // U+FF11 is FULLWIDTH DIGIT ONE + !("25\u{FF11}.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("20\u{FF11}.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("2\u{FF11}0.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("10\u{FF11}.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("1\u{FF11}0.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("\u{FF11}00.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("00\u{FF11}.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("0\u{FF11}0.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("0\u{FF11}.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("\u{FF11}0.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + !("\u{FF11}.0.0.0" is net.IPv4AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4AddressString# + } + ["IPv6AddressString can't contain unicode digits"] { + !("\u{FF11}::" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("fe80::%\u{FF11}" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::25\u{FF11}.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::20\u{FF11}.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::2\u{FF11}0.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::10\u{FF11}.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::1\u{FF11}0.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::\u{FF11}00.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::00\u{FF11}.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::0\u{FF11}0.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::0\u{FF11}.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::\u{FF11}0.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + !("::\u{FF11}.0.0.0" is net.IPv6AddressString) +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6AddressString# + } + ["IPv4AddressPortString can't contain unicode digits in the port"] { + !("127.0.0.1:\u{FF11}" is net.IPAddressPortString) +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPAddressPortString# + } + ["IPv6AddressPortString can't contain unicode digits in the port"] { + !("[::1]:\u{FF11}" is net.IPAddressPortString) +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPAddressPortString# + } + ["IPv4CIDRString can't contain unicode digits in the suffix"] { + !("10.0.0.0/\u{FF11}" is net.IPv4CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv4CIDRString# + } + ["IPv6CIDRString can't contain unicode digits in the suffix"] { + !("::1/\u{FF11}" is net.IPv6CIDRString) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6CIDRString# + } + } + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/net.pkl`/examples. + ["expandIPv6AddressString"] { + net.expandIPv6AddressString("fe80::") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + net.expandIPv6AddressString("fe80::1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + net.expandIPv6AddressString("::aa") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + } + ["expandIPv6AddressString with scoped addresses"] { + net.expandIPv6AddressString("fe80:0000:0000:0000:0000:0000:0000:00%1") // 39 bytes long +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + net.expandIPv6AddressString("fe80::%0") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + net.expandIPv6AddressString("fe80:0:0:0:5:6:7:8%1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + net.expandIPv6AddressString("fe80::%000") // we don't canonicalize scope ids here +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + net.expandIPv6AddressString("fe80::%001") // that happens in compressIPv6AddressString +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + } + ["expandIPv6AddressString with IPv4 suffix"] { + net.expandIPv6AddressString("ffff:ffff:ffff:ffff:0:0:255.255.255.255") // 39 bytes long +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + net.expandIPv6AddressString("::1.2.3.4") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + net.expandIPv6AddressString("2001:db8::1.2.3.4") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + net.expandIPv6AddressString("a:b:c:d:e:f:001.000.030.000") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/expandIPv6AddressString(). + } + ["compressIPv6AddressString"] { + net.compressIPv6AddressString("0001:0002:0003:0004:0005:0006:0007:0008") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("fe80:000:000:000:1:000:000:1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("fe80::0001:0000:0000:0001") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("1:2:3:4:0:6:7:8") // :: shouldn't compress a single field +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("1:2:3:4::6:7:8") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("::") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("::0:0") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("FE80::A:B:C:D:E:F") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("2001:0:0:1:0:0:0:1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("2001:db8:0:0:1:0:0:1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + } + ["compressIPv6AddressString with scoped addresses"] { + net.compressIPv6AddressString("fe80:0000:0000:0000:0005:0006:0007:0008%0") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("fe80::1:0%0") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("fe80::%0") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("fe80::%1") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("fe80::%000") // we canonicalize scope ids here +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("fe80::%001") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + } + ["compressIPv6AddressString with IPv4 suffix"] { + net.compressIPv6AddressString("::ffff:1.2.3.4") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("0000:0000:0000:0000:0000:ffff:001.020.000.004") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("fe80:0:0:0::1.2.3.4") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("fe80:0:0:0:0:0:0.0.0.0") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + net.compressIPv6AddressString("::0.0.0.0") +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/compressIPv6AddressString(). + } + ["IPv6Address.toString()"] { + net.IPv6Address("fe80::1").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + net.IPv6Address("101:1001:1010:110:100:1000:1100:1110").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + net.IPv6Address("::").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + net.IPv6Address("::0:1").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + net.IPv6Address("fe80::0").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + net.IPv6Address("fe80:0000:0000:0000:0000:0000:0001:0000").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + net.IPv6Address("::ffff:7f00:1").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + net.IPv6Address("64:ff9b::c000:0221").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + net.IPv6Address("2001:db8:122:344::192.0.2.33").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + net.IPv6Address("fe80::1%1").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + net.IPv6Address("ff11::1%02").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + net.IPv6Address("fe80::%0").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toString(). + } + ["IPv6Address.toExpandedString()"] { + net.IPv6Address("fe80::1").toExpandedString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toExpandedString(). + net.IPv6Address("::").toExpandedString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toExpandedString(). + net.IPv6Address("::1").toExpandedString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toExpandedString(). + net.IPv6Address("2001:db8::").toExpandedString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toExpandedString(). + net.IPv6Address("fe80::1%1").toExpandedString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toExpandedString(). + net.IPv6Address("fe80::1%0").toExpandedString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/ +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `net.pkl`/IPv6Address#toExpandedString(). + } + } diff --git a/pkl-pantrysnapshot/pkl.experimental.net/tests/u128.pkl b/pkl-pantrysnapshot/pkl.experimental.net/tests/u128.pkl new file mode 100755 index 00000000..14265232 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.net/tests/u128.pkl @@ -0,0 +1,318 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.net.tests.u128 +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/u128.pkl`/ + + amends "pkl:test" + + import "pkl:math" + import "../u128.pkl" + + local someValue = u128.UInt128(0x74ab3ef8, 0x09bfce41, 0xab38bef1, 0x10efba83) +// ^^^^^^^^^ definition local someValue_23 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/u128.pkl`/facts. + ["le"] { + u128.zero.le(u128.zero) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#le(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. + u128.zero.le(u128.one) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#le(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. + u128.zero.le(u128.maxUInt128) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#le(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. + someValue.le(u128.maxUInt128) +// ^^^^^^^^^ reference local someValue_23 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#le(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. + !u128.maxUInt128.le(someValue) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#le(). +// ^^^^^^^^^ reference local someValue_23 + u128.zero.le(someValue) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#le(). +// ^^^^^^^^^ reference local someValue_23 + someValue.le(someValue) +// ^^^^^^^^^ reference local someValue_23 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#le(). +// ^^^^^^^^^ reference local someValue_23 + } + + ["lt"] { + !u128.zero.lt(u128.zero) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lt(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. + u128.zero.lt(u128.one) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lt(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. + u128.zero.lt(u128.maxUInt128) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lt(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. + someValue.lt(u128.maxUInt128) +// ^^^^^^^^^ reference local someValue_23 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lt(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. + !u128.maxUInt128.lt(someValue) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lt(). +// ^^^^^^^^^ reference local someValue_23 + u128.zero.lt(someValue) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lt(). +// ^^^^^^^^^ reference local someValue_23 + !someValue.lt(someValue) +// ^^^^^^^^^ reference local someValue_23 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lt(). +// ^^^^^^^^^ reference local someValue_23 + } + ["=="] { + u128.zero == u128.zero +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. + u128.zero != u128.one +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. + u128.one == u128.one +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. + u128.one != u128.maxUInt128 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. + u128.maxUInt128 == u128.maxUInt128 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. + u128.zero != u128.UInt128(0, 0, 1, 0) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + u128.zero != u128.UInt128(0, 1, 0, 0) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + u128.zero != u128.UInt128(1, 0, 0, 0) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + } + } + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `tests/u128.pkl`/examples. + ["toString"] { + u128.one.toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.maxUInt128.toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + module.catch(() -> +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). + u128.UInt128(math.maxUInt32 + 1, math.maxUInt32 + 2, math.maxUInt32 + 3, math.maxUInt32 + 4).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + ) + } + + ["and"] { + someValue.and(u128.zero).toString() +// ^^^^^^^^^ reference local someValue_23 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#and(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.zero.and(someValue).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#and(). +// ^^^^^^^^^ reference local someValue_23 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.maxUInt128.and(someValue).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#and(). +// ^^^^^^^^^ reference local someValue_23 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + someValue.and(u128.maxUInt128).toString() +// ^^^^^^^^^ reference local someValue_23 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#and(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + } + + ["or"] { + someValue.or(u128.zero).toString() +// ^^^^^^^^^ reference local someValue_23 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#or(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.zero.or(someValue).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#or(). +// ^^^^^^^^^ reference local someValue_23 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.maxUInt128.or(someValue).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#or(). +// ^^^^^^^^^ reference local someValue_23 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + someValue.or(u128.maxUInt128).toString() +// ^^^^^^^^^ reference local someValue_23 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#or(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + } + + ["shl"] { + u128.one.shl(0).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.one.shl(1).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.one.shl(19).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.one.shl(32).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.one.shl(33).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.one.shl(51).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.one.shl(64).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.one.shl(65).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + u128.one.shl(84).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + } + + ["add"] { + u128.one.add(u128.one).toString() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#add(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + someValue.add(someValue).toString() +// ^^^^^^^^^ reference local someValue_23 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#add(). +// ^^^^^^^^^ reference local someValue_23 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + someValue.add(u128.zero).toString() +// ^^^^^^^^^ reference local someValue_23 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#add(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). + } + + ["seq"] { + u128.zero.seq(u128.UInt128(0, 0, 0, 64)).length// +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#length. + // u128.zero.seq(u128.UInt128(0, 0, 1, 64)).length + // womp womp + // java.lang.NegativeArraySizeException: -2147483648 + } + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.net/u128.pkl b/pkl-pantrysnapshot/pkl.experimental.net/u128.pkl new file mode 100755 index 00000000..19dc2b16 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.net/u128.pkl @@ -0,0 +1,688 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Who was it that said we'd never need more than 64 bits?? + /// Some tasks work best with unsigned 128-bit integers, eg. working with IPv6 addresses. + /// This module implements a [UInt128] type composed out of 4 [UInt]s that can handle limited bit-wise and arithmetic operations. + /// NB: this task is a better fit for [UInt32], but it cannot be used here as we rely on shifting bits off the significant end and Pkl's implementation doesn't permit this + module pkl.experimental.net.u128 +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/ + + import "pkl:math" + + /// A [UInt128] with value 0. + const zero: UInt128 = UInt128(0, 0, 0, 0) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/zero. +// documentation +// > A [`UInt128`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L37,C7) with value 0. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + /// A [UInt128] with value 1. + const one: UInt128 = UInt128(0, 0, 0, 1) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/one. +// documentation +// > A [`UInt128`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L37,C7) with value 1. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + /// The maximum [UInt128] value. + const maxUInt128: UInt128 = UInt128(math.maxUInt32, math.maxUInt32, math.maxUInt32, math.maxUInt32) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/maxUInt128. +// documentation +// > The maximum [`UInt128`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L37,C7) value. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + + /// Creates a [UInt128] with components [UInt32]s [high], [midHigh], [midLow], and [low] + const function UInt128(high: UInt32, midHigh: UInt32, midLow: UInt32, low: UInt32): UInt128 = new { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// documentation +// > Creates a [`UInt128`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L37,C7) with components [`UInt32`](pkl-lsp://stdlib/base.pkl#L956,C11)s [`high`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L32,C24), [`midHigh`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L32,C38), [`midLow`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L32,C55), and [`low`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L32,C71) +// ^^^^ definition local high_32 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# +// ^^^^^^^ definition local midHigh_32 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# +// ^^^^^^ definition local midLow_32 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# +// ^^^ definition local low_32 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# + words = List(low, midLow, midHigh, high) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/words. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^ reference local low_32 +// ^^^^^^ reference local midLow_32 +// ^^^^^^^ reference local midHigh_32 +// ^^^^ reference local high_32 + } + + /// An unsigned 128-bit integer. + class UInt128 { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// documentation +// > An unsigned 128-bit integer. + words: List(length == 4) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#words. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. + hidden hihi: UInt = words[3] +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#words. + hidden hilo: UInt = words[2] +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#words. + hidden lohi: UInt = words[1] +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#words. + hidden lolo: UInt = words[0] +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#words. + + local self = this +// ^^^^ definition local self_44 + + function toString(): String = new Listing { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#toString(). +// documentation +// > Returns a string representation of `this`. +// > +// > This method is used to convert the values of string interpolation expressions to strings. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + hihi.toRadixString(16).padStart(8, "0") +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + hilo.toRadixString(16).padStart(8, "0") +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + lohi.toRadixString(16).padStart(8, "0") +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + lolo.toRadixString(16).padStart(8, "0") +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + }.join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + + /// Bitwise AND of this integer and [n]. + function and(other: UInt128): UInt128 = UInt128( +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#and(). +// documentation +// > Bitwise AND of this integer and `n`. +// ^^^^^ definition local other_54 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + self.hihi.and(other.hihi), +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^^ reference local other_54 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. + self.hilo.and(other.hilo), +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^^ reference local other_54 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. + self.lohi.and(other.lohi), +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^^ reference local other_54 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. + self.lolo.and(other.lolo) +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^^ reference local other_54 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. + ) + + /// Bitwise OR of this integer and [n]. + function or(other: UInt128): UInt128 = UInt128( +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#or(). +// documentation +// > Bitwise OR of this integer and `n`. +// ^^^^^ definition local other_62 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + self.hihi.or(other.hihi), +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^ reference local other_62 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. + self.hilo.or(other.hilo), +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^ reference local other_62 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. + self.lohi.or(other.lohi), +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^ reference local other_62 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. + self.lolo.or(other.lolo) +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^ reference local other_62 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. + ) + + /// Returns true if this integer is less than or equal to [other]. + function le(other: UInt128): Boolean = self.words == other.words || self.lt(other) +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#le(). +// documentation +// > Returns true if this integer is less than or equal to [`other`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L70,C15). +// ^^^^^ definition local other_70 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^ reference local self_44 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#words. +// ^^^^^ reference local other_70 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#words. +// ^^^^ reference local self_44 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lt(). +// ^^^^^ reference local other_70 + + /// Returns true if this integer is strictly less than [other]. + function lt(other: UInt128): Boolean = +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lt(). +// documentation +// > Returns true if this integer is strictly less than [`other`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L73,C15). +// ^^^^^ definition local other_73 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + self.hihi < other.hihi || self.hihi == other.hihi && ( +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^^ reference local other_73 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^^ reference local other_73 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. + self.hilo < other.hilo || self.hilo == other.hilo && ( +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^ reference local other_73 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^ reference local other_73 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. + self.lohi < other.lohi || self.lohi == other.lohi && ( +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^ reference local other_73 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^ reference local other_73 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. + self.lolo < other.lolo +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^^ reference local other_73 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. + ))) + + /// Shifts this integer left by [n] bits. + function shl(n: UInt): UInt128 = +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// documentation +// > Shifts this integer left by [`n`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L81,C16) bits. +// ^ definition local n_81 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# + if (n == 0) self +// ^ reference local n_81 +// ^^^^ reference local self_44 + else if (n > 32) self.shl(32).shl(n - 32) // just recurse, 5head! +// ^ reference local n_81 +// ^^^^ reference local self_44 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#shl(). +// ^ reference local n_81 + // not only is this n == 32 case more efficient, but it protects us from the fact that Pkl has no UInt64 type + // we would be in for a bad time if we shifted a [math.maxUInt32] left 32 bits into the sign bit of [Int] + else if (n == 32) UInt128(self.hilo, self.lohi, self.lolo, 0) +// ^ reference local n_81 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. + else UInt128( +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). + self.hihi.shl(n).and(math.maxUInt32).or(self.hilo.ushr(32 - n)), +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^ reference local n_81 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^ reference local n_81 + self.hilo.shl(n).and(math.maxUInt32).or(self.lohi.ushr(32 - n)), +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^ reference local n_81 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^ reference local n_81 + self.lohi.shl(n).and(math.maxUInt32).or(self.lolo.ushr(32 - n)), +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^ reference local n_81 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#ushr(). +// ^ reference local n_81 + self.lolo.shl(n).and(math.maxUInt32) +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). +// ^ reference local n_81 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + ) + + /// Return the sum of this integer and [other]. + function add(other: UInt128): UInt128 = new { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#add(). +// documentation +// > Return the sum of this integer and [`other`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L95,C16). +// ^^^^^ definition local other_95 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# + local complement = math.maxUInt32 - other.lolo +// ^^^^^^^^^^ definition local complement_96 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^^ reference local other_95 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. + local loloOverflows = self.lolo > complement +// ^^^^^^^^^^^^^ definition local loloOverflows_97 +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^^^^^^^ reference local complement_96 + local lolo = +// ^^^^ definition local lolo_98 + if (loloOverflows) self.lolo - math.maxUInt32 + other.lolo - 1 +// ^^^^^^^^^^^^^ reference local loloOverflows_97 +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^^ reference local other_95 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. + else self.lolo + other.lolo +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^^ reference local other_95 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. + + local lohiComplement = math.maxUInt32 - other.lohi +// ^^^^^^^^^^^^^^ definition local lohiComplement_102 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^^ reference local other_95 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. + local lohiCarry = if (loloOverflows) 1 else 0 +// ^^^^^^^^^ definition local lohiCarry_103 +// ^^^^^^^^^^^^^ reference local loloOverflows_97 + local lohiOverflows = (self.lohi + lohiCarry) > lohiComplement +// ^^^^^^^^^^^^^ definition local lohiOverflows_104 +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^^^^^ reference local lohiCarry_103 +// ^^^^^^^^^^^^^^ reference local lohiComplement_102 + local lohi = +// ^^^^ definition local lohi_105 + if (lohiOverflows) self.lohi - math.maxUInt32 + other.lohi - 1 + lohiCarry +// ^^^^^^^^^^^^^ reference local lohiOverflows_104 +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^^ reference local other_95 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^^^^^ reference local lohiCarry_103 + else self.lohi + other.lohi + lohiCarry +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^ reference local other_95 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^^^^^ reference local lohiCarry_103 + + local hiloComplement = math.maxUInt32 - other.hilo +// ^^^^^^^^^^^^^^ definition local hiloComplement_109 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^^ reference local other_95 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. + local hiloCarry = if (lohiOverflows) 1 else 0 +// ^^^^^^^^^ definition local hiloCarry_110 +// ^^^^^^^^^^^^^ reference local lohiOverflows_104 + local hiloOverflows = (self.hilo + hiloCarry) > hiloComplement +// ^^^^^^^^^^^^^ definition local hiloOverflows_111 +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^^^^^ reference local hiloCarry_110 +// ^^^^^^^^^^^^^^ reference local hiloComplement_109 + local hilo = +// ^^^^ definition local hilo_112 + if (hiloOverflows) self.hilo - math.maxUInt32 + other.hilo - 1 + hiloCarry +// ^^^^^^^^^^^^^ reference local hiloOverflows_111 +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^^ reference local other_95 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^^^^^ reference local hiloCarry_110 + else self.hilo + other.hilo + hiloCarry +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^ reference local other_95 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^^^^^ reference local hiloCarry_110 + + local hihiCarry = if (hiloOverflows) 1 else 0 +// ^^^^^^^^^ definition local hihiCarry_116 +// ^^^^^^^^^^^^^ reference local hiloOverflows_111 + local hihi = (self.hihi + other.hihi + hihiCarry).and(math.maxUInt32) +// ^^^^ definition local hihi_117 +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^^ reference local other_95 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^^^^^^ reference local hihiCarry_116 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + words = List(lolo, lohi, hilo, hihi) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#words. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^ reference local lolo_98 +// ^^^^ reference local lohi_105 +// ^^^^ reference local hilo_112 +// ^^^^ reference local hihi_117 + } + + /// Generate a sequence of [UInt128] between this integer and [other], inclusive. + /// Behaves like [IntSeq]. + function seq(other: UInt128): Listing = +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// documentation +// > Generate a sequence of [`UInt128`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L37,C7) between this integer and [`other`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.net/u128.pkl#L123,C16), inclusive. +// > Behaves like [`IntSeq`](pkl-lsp://stdlib/base.pkl#L2792,C16). +// ^^^^^ definition local other_123 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128# + if (self.hihi == other.hihi) +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. + if (self.hilo == other.hilo) +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. + if (self.lohi == other.lohi) new { +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. + for (ll in IntSeq(self.lolo, other.lolo)) { UInt128(self.hihi, self.hilo, self.lohi, ll) } +// ^^ definition local ll_127 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^ reference local ll_127 + } + else new { + ...UInt128(self.hihi, self.hilo, self.lohi, self.lolo).seq(UInt128(self.hihi, self.hilo, self.lohi, math.maxUInt32)) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + for (lh in IntSeq(self.lohi, other.lohi)) { +// ^^ definition local lh_131 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. + ...UInt128(self.hihi, self.hilo, lh, 0).seq(UInt128(self.hihi, self.hilo, lh, math.maxUInt32)) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^ reference local lh_131 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^ reference local lh_131 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + } + ...UInt128(other.hihi, other.hilo, other.lohi, 0).seq(UInt128(other.hihi, other.hilo, other.lohi, other.lolo)) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. + } + else new { + ...UInt128(self.hihi, self.hilo, self.lohi, self.lolo).seq(UInt128(self.hihi, self.hilo, math.maxUInt32, math.maxUInt32)) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + for (hl in IntSeq(self.hilo, other.hilo)) { +// ^^ definition local hl_138 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. + ...UInt128(self.hihi, hl, 0, 0).seq(UInt128(self.hihi, hl, math.maxUInt32, math.maxUInt32)) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^ reference local hl_138 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^ reference local hl_138 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + } + ...UInt128(other.hihi, other.hilo, 0, 0).seq(UInt128(other.hihi, other.hilo, other.lohi, other.lolo)) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. + } + else new { + ...UInt128(self.hihi, self.hilo, self.lohi, self.lolo).seq(UInt128(self.hihi, math.maxUInt32, math.maxUInt32, math.maxUInt32)) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + for (hh in IntSeq(self.hilo, other.hilo)) { +// ^^ definition local hh_145 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). +// ^^^^ reference local self_44 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. + ...UInt128(hh, 0, 0, 0).seq(UInt128(hh, math.maxUInt32, math.maxUInt32, math.maxUInt32)) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^ reference local hh_145 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^ reference local hh_145 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt32. + } + ...UInt128(other.hihi, 0, 0, 0).seq(UInt128(other.hihi, other.hilo, other.lohi, other.lolo)) +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#seq(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128(). +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hihi. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#hilo. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lohi. +// ^^^^^ reference local other_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.net 1.2.1 `u128.pkl`/UInt128#lolo. + } + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.structuredRead/PklProject b/pkl-pantrysnapshot/pkl.experimental.structuredRead/PklProject new file mode 100755 index 00000000..44d2f90f --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.structuredRead/PklProject @@ -0,0 +1,29 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + amends ".../basePklProject.pkl" + + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 PklProject/package. + version = "1.0.4" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 PklProject/version. + } + + dependencies { +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 PklProject/dependencies. + ["deepToTyped"] = import("../pkl.experimental.deepToTyped/PklProject") + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/envVars/envVars.pkl b/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/envVars/envVars.pkl new file mode 100755 index 00000000..b0f0f8a4 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/envVars/envVars.pkl @@ -0,0 +1,48 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Example reading values from the enviroment to fill + /// in a Pkl class. + /// + /// Try running `pkl eval envVars.pkl` + module envVars +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/envVars/envVars.pkl`/ + import ".../structuredRead.pkl" + + class EnvConfig { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/envVars/envVars.pkl`/EnvConfig# + SHELL: String? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/envVars/envVars.pkl`/EnvConfig#SHELL. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + USER: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/envVars/envVars.pkl`/EnvConfig#USER. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + PWD: String? +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/envVars/envVars.pkl`/EnvConfig#PWD. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + LANG: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/envVars/envVars.pkl`/EnvConfig#LANG. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/envVars/envVars.pkl`/output. + value = structuredRead.fromEnv.fill(EnvConfig) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/envVars/envVars.pkl`/value. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fromEnv. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/envVars/envVars.pkl`/EnvConfig# + } diff --git a/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/helmStyle/chart.pkl b/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/helmStyle/chart.pkl new file mode 100755 index 00000000..8ab3ddba --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/helmStyle/chart.pkl @@ -0,0 +1,37 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Example of using structuredRead to recreate the behaviour of `values` + /// in helm charts. + /// + /// In this example the default values are loaded from values.pkl, but any + /// value can be overwritten by passing `-p =` to `pkl eval`. + /// + /// Try running `pkl eval chart.pkl -p nameOverride="BetterVector" -p replicas=30 -p args.1="/config"` + /// + /// The overwritten values are automatically coersed into the same type as the default + /// so `replicas` retains its `Int` type, and the string value `30` is automatically + /// converted as needed. + module chart +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/chart.pkl`/ + + amends "values.pkl" + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/chart.pkl`/output. + value = module.fromExternalProps +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/chart.pkl`/value. +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/fromExternalProps. + } diff --git a/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/helmStyle/values.pkl b/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/helmStyle/values.pkl new file mode 100755 index 00000000..0195ee7a --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/helmStyle/values.pkl @@ -0,0 +1,159 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Based on the Vector helm chart + /// See Vector helm documentation to learn more: + /// https://vector.dev/docs/setup/installation/package-managers/helm/ + module values +//^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/ + + // !!! IMPORTANT !!! + // This property **must** be fixed *and* hidden, otherwise a stack overflow will occur! + hidden fixed fromExternalProps: module = +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/fromExternalProps. + import(".../structuredRead.pkl").fromExternalProps.fill(module) as module +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fromExternalProps. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). + + nameOverride = "" +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/nameOverride. + + fullnameOverride = "" +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/fullnameOverride. + + role = "Agent" +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/role. + + rollWorkload = true +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/rollWorkload. + + commonLabels {} +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/commonLabels. + + image { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/image. + repository = "timberio/vector" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/repository. + pullPolicy = "IfNotPresent" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/pullPolicy. + pullSecrets {} +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/pullSecrets. + tag = "" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/tag. + sha = "" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/sha. + base = "" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/base. + } + + /// Specify the number of Pods to create. Valid for the "Aggregator" and "Stateless-Aggregator" roles. + replicas = 1 +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/replicas. +//documentation +//> Specify the number of Pods to create. Valid for the "Aggregator" and "Stateless-Aggregator" roles. + + /// Specify the [podManagementPolicy](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-management-policies) + /// for the StatefulSet. Valid for the "Aggregator" role. + podManagementPolicy = "OrderedReady" +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/podManagementPolicy. +//documentation +//> Specify the [podManagementPolicy](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-management-policies) +//> for the StatefulSet. Valid for the "Aggregator" role. + + /// Create a Secret resource for Vector to use. + secrets { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/secrets. +//documentation +//> Create a Secret resource for Vector to use. + generic {} +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/generic. + } + + autoscaling { +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/autoscaling. + enabled = false +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/enabled. + `external` = false +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/external. + annotations {} +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/annotations. + minReplicas = 1 +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/minReplicas. + maxReplicas = 10 +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/maxReplicas. + targetCPUUtilizationPercentage = 80 +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/targetCPUUtilizationPercentage. + targetMemoryUtilizationPercentage = null +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/targetMemoryUtilizationPercentage. + customMetric {} +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/customMetric. + behavior {} +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/behavior. + } + podDisruptionBudget { +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/podDisruptionBudget. + enabled = false +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/enabled. + minAvailable = 1 +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/minAvailable. + maxUnavailable = null +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/maxUnavailable. + } + rbac { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/rbac. + create = true +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/create. + } + psp { +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/psp. + create = false +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/create. + } + serviceAccount { +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/serviceAccount. + create = true +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/create. + annotations {} +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/annotations. + name = null +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/name. + automountToken = true +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/automountToken. + } + podAnnotations {} +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/podAnnotations. + podLabels { +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/podLabels. + `vector.dev/exclude` = "true" +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/`vector.dev/exclude`. + } + podPriorityClassName = "" +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/podPriorityClassName. + podHostNetwork = false +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/podHostNetwork. + podSecurityContext {} +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/podSecurityContext. + workloadResourceAnnotations {} +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/workloadResourceAnnotations. + securityContext {} +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/securityContext. + command {} +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/command. + args { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/helmStyle/values.pkl`/args. + "--config-dir" + "/etc/vector/" + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/https/https.pkl b/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/https/https.pkl new file mode 100755 index 00000000..757c0c77 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.structuredRead/examples/https/https.pkl @@ -0,0 +1,47 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Example using structureRead to get resources https + /// resources. Not necessarily recommended usage. + /// + /// Try `pkl eval fromHttps.pkl` + module https +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/https/https.pkl`/ + + import ".../structuredRead.pkl" + + Http { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/https/https.pkl`/Http. + `raw.githubusercontent.com/apple/pkl-pantry` { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/https/https.pkl`/`raw.githubusercontent.com/apple/pkl-pantry`. + `8fcea0e535d2eb473545305d8a573144f2b0d33d` { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/https/https.pkl`/8fcea0e535d2eb473545305d8a573144f2b0d33d. + `README.adoc` {} +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/https/https.pkl`/`README.adoc`. + `CONTRIBUTING.adoc` {} +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/https/https.pkl`/`CONTRIBUTING.adoc`. + } + } + } + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/https/https.pkl`/output. + value = structuredRead.fromHttps.fill(Http) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/https/https.pkl`/value. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fromHttps. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `examples/https/https.pkl`/Http. + } diff --git a/pkl-pantrysnapshot/pkl.experimental.structuredRead/structuredRead.pkl b/pkl-pantrysnapshot/pkl.experimental.structuredRead/structuredRead.pkl new file mode 100755 index 00000000..05988716 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.structuredRead/structuredRead.pkl @@ -0,0 +1,790 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.structuredRead.structuredRead +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ + import "pkl:reflect" + import "@deepToTyped/deepToTyped.pkl" + + /// Configures structureRead to read from environment variables + /// + /// ``` + /// import "structuredRead.pkl" + /// + /// class Environment { + /// SHELL: String + /// PWD: String + /// USER: Int + /// } + /// + /// environment = structuredRead.fromEnv.fill(Environment) + /// ``` + hidden fixed fromEnv: module = (module) { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fromEnv. +// documentation +// > Configures structureRead to read from environment variables +// > +// > ``` +// > import "structuredRead.pkl" +// > +// > class Environment { +// > SHELL: String +// > PWD: String +// > USER: Int +// > } +// > +// > environment = structuredRead.fromEnv.fill(Environment) +// > ``` + inputScheme = "env:" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. +// documentation +// > The scheme used to read resources from. +// > +// > By default, this is `"prop:"` so values are read from external +// > properties passed using the `-p` flag. + pathSeparator = "_" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathSeparator. +// documentation +// > Path separator used to when building resource URI. +// > +// > Default is `.` which means that nested values are passed in +// > using a dot seperated path as the key value. + } + + /// Configures structureRead to read from external properties + /// + /// ``` + /// import "structuredRead.pkl" + /// + /// class Config { + /// name: String + /// location: String + /// age: Int + /// } + /// + /// config = structuredRead.fromHttps.fill(Config) + /// ``` + hidden fixed fromExternalProps: module = (module) { +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fromExternalProps. +// documentation +// > Configures structureRead to read from external properties +// > +// > ``` +// > import "structuredRead.pkl" +// > +// > class Config { +// > name: String +// > location: String +// > age: Int +// > } +// > +// > config = structuredRead.fromHttps.fill(Config) +// > ``` + inputScheme = "prop:" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. +// documentation +// > The scheme used to read resources from. +// > +// > By default, this is `"prop:"` so values are read from external +// > properties passed using the `-p` flag. + pathSeparator = "." +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathSeparator. +// documentation +// > Path separator used to when building resource URI. +// > +// > Default is `.` which means that nested values are passed in +// > using a dot seperated path as the key value. + } + + /// Configures structureRead to read from https:// resources + /// + /// ``` + /// import "structuredRead.pkl" + /// + /// Data { + /// `apple.com` {} + /// } + /// + /// data = structuredRead.fromHttps.fill(Data) + /// ``` + hidden fixed fromHttps: module = (module) { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fromHttps. +// documentation +// > Configures structureRead to read from https:// resources +// > +// > ``` +// > import "structuredRead.pkl" +// > +// > Data { +// > `apple.com` {} +// > } +// > +// > data = structuredRead.fromHttps.fill(Data) +// > ``` + inputScheme = "https:" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. +// documentation +// > The scheme used to read resources from. +// > +// > By default, this is `"prop:"` so values are read from external +// > properties passed using the `-p` flag. + pathSeparator = "/" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathSeparator. +// documentation +// > Path separator used to when building resource URI. +// > +// > Default is `.` which means that nested values are passed in +// > using a dot seperated path as the key value. + pathTemplate = (path) -> "\(inputScheme)//\(path.join(pathSeparator))" +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathTemplate. +// documentation +// > Template used to convert a path of elements into a resource URI. +// > +// > Default joins the path components with [`pathSeparator`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.structuredRead/structuredRead.pkl#L112,C1) and +// > prepends the [`inputScheme`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.structuredRead/structuredRead.pkl#L106,C1). +// ^^^^ definition local path_70 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. +// ^^^^ reference local path_70 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathSeparator. + } + + /// Takes a given class or module and attempts to fill the properties from external resources. + /// + /// Resources are read in by constructing resource URIs from the structure of the provided class + /// or modules. The read values are then coerced into the types specified in the class or module, making + /// it easy to get external properties (using [fromExternalProps] and passed using the `-p` flag) + /// or environment variables (using [fromEnv]) into a structured and typed format. + /// + /// When embeded in another application, this Pkl module can be used to provide a + /// basic ability to override loaded configuration using CLI flags. The application + /// will need to parse the passed flags, then provide them to Pkl via a custom + /// [Resource Reader](https://pkl-lang.org/main/current/language-reference/index.html#extending-resource-readers), + /// or by passing them in as external properties. + function fill(target: Class|Module|Dynamic) = +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// documentation +// > Takes a given class or module and attempts to fill the properties from external resources. +// > +// > Resources are read in by constructing resource URIs from the structure of the provided class +// > or modules. The read values are then coerced into the types specified in the class or module, making +// > it easy to get external properties (using [`fromExternalProps`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.structuredRead/structuredRead.pkl#L51,C1) and passed using the `-p` flag) +// > or environment variables (using [`fromEnv`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.structuredRead/structuredRead.pkl#L33,C1)) into a structured and typed format. +// > +// > When embeded in another application, this Pkl module can be used to provide a +// > basic ability to override loaded configuration using CLI flags. The application +// > will need to parse the passed flags, then provide them to Pkl via a custom +// > [Resource Reader](https://pkl-lang.org/main/current/language-reference/index.html#extending-resource-readers), +// > or by passing them in as external properties. +// ^^^^^^ definition local target_85 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + let (targetClass = +// ^^^^^^^^^^^ definition local targetClass_86 + if (!(target is Class)) +// ^^^^^^ reference local target_85 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# + target.getClass() +// ^^^^^^ reference local target_85 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + else + target +// ^^^^^^ reference local target_85 + ) + let (mappedInputs = +// ^^^^^^^^^^^^ definition local mappedInputs_92 + if (targetClass == Dynamic) +// ^^^^^^^^^^^ reference local targetClass_86 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + applyToDynamic(List(), target) +// ^^^^^^^^^^^^^^ reference local applyToDynamic_185 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^ reference local target_85 + else + applyToClass(targetClass, List())) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/applyToClass(). +// ^^^^^^^^^^^ reference local targetClass_86 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + if (assertNoFailures(targetClass, mappedInputs) && targetClass != Dynamic) +// ^^^^^^^^^^^^^^^^ reference local assertNoFailures_138 +// ^^^^^^^^^^^ reference local targetClass_86 +// ^^^^^^^^^^^^ reference local mappedInputs_92 +// ^^^^^^^^^^^ reference local targetClass_86 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + deepToTyped.apply(targetClass, mappedInputs) +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped 1.1.1 `deepToTyped.pkl`/apply(). +// ^^^^^^^^^^^ reference local targetClass_86 +// ^^^^^^^^^^^^ reference local mappedInputs_92 + else + mappedInputs +// ^^^^^^^^^^^^ reference local mappedInputs_92 + + /// The scheme used to read resources from. + /// + /// By default, this is `"prop:"` so values are read from external + /// properties passed using the `-p` flag. + hidden inputScheme: String(matches(Regex(#"[\w-]+:"#))) +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. +// documentation +// > The scheme used to read resources from. +// > +// > By default, this is `"prop:"` so values are read from external +// > properties passed using the `-p` flag. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + + /// Path separator used to when building resource URI. + /// + /// Default is `.` which means that nested values are passed in + /// using a dot seperated path as the key value. + hidden pathSeparator: String +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathSeparator. +// documentation +// > Path separator used to when building resource URI. +// > +// > Default is `.` which means that nested values are passed in +// > using a dot seperated path as the key value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Template used to convert a path of elements into a resource URI. + /// + /// Default joins the path components with [pathSeparator] and + /// prepends the [inputScheme]. + hidden pathTemplate: (List) -> String = (path: List) -> "\(inputScheme)\(path.join(pathSeparator))" +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathTemplate. +// documentation +// > Template used to convert a path of elements into a resource URI. +// > +// > Default joins the path components with [`pathSeparator`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.structuredRead/structuredRead.pkl#L112,C1) and +// > prepends the [`inputScheme`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.structuredRead/structuredRead.pkl#L106,C1). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ definition local path_118 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. +// ^^^^ reference local path_118 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathSeparator. + + /// Debug hook for overriding how values are read. + hidden readFunc = (s) -> read?(s) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/readFunc. +// documentation +// > Debug hook for overriding how values are read. +// ^ definition local s_121 +// ^ reference local s_121 + + function applyToClass(target: Class, path: List): Mapping = +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/applyToClass(). +// ^^^^^^ definition local target_123 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^ definition local path_123 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + let (reflected = reflect.Class(target)) +// ^^^^^^^^^ definition local reflected_124 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^^^^^^ reference local target_123 + new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + for (name, property in reflected.properties) { +// ^^^^ definition local name_126 +// ^^^^^^^^ definition local property_126 +// ^^^^^^^^^ reference local reflected_124 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#properties. + when (property.type is Coerceable) { +// ^^^^^^^^ reference local property_126 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Coerceable# + [name] = let (potentialValue = readValueToTarget(path, name, property)) +// ^^^^ reference local name_126 +// ^^^^^^^^^^^^^^ definition local potentialValue_128 +// ^^^^^^^^^^^^^^^^^ reference local readValueToTarget_247 +// ^^^^ reference local path_123 +// ^^^^ reference local name_126 +// ^^^^^^^^ reference local property_126 + if (!(potentialValue is ReadFailure)) potentialValue +// ^^^^^^^^^^^^^^ reference local potentialValue_128 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ReadFailure# +// ^^^^^^^^^^^^^^ reference local potentialValue_128 + else if (property.type is reflect.NullableType) property.defaultValue +// ^^^^^^^^ reference local property_126 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType# +// ^^^^^^^^ reference local property_126 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#defaultValue. + else property.defaultValue ?? potentialValue +// ^^^^^^^^ reference local property_126 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#defaultValue. +// ^^^^^^^^^^^^^^ reference local potentialValue_128 + } + } + } + + typealias Coerceable = reflect.DeclaredType | reflect.NullableType | reflect.TypeAlias | reflect.UnknownType +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Coerceable# +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias# +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnknownType# + + local function assertNoFailures(target: Class, output: Mapping|Dynamic): Boolean = +// ^^^^^^^^^^^^^^^^ definition local assertNoFailures_138 +// ^^^^^^ definition local target_138 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ definition local output_138 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + let (fails = findFailures(output)) +// ^^^^^ definition local fails_139 +// ^^^^^^^^^^^^ reference local findFailures_151 +// ^^^^^^ reference local output_138 + fails.isEmpty || +// ^^^^^ reference local fails_139 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + let (msg = new Listing { +// ^^^ definition local msg_141 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + "Error processing \(if (fails.length > 1) "properties" else "property") in \(target):\n" +// ^^^^^ reference local fails_139 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^^ reference local target_138 + local maxPathLength = fails.map((f) -> f.path.join(pathSeparator).length).max +// ^^^^^^^^^^^^^ definition local maxPathLength_143 +// ^^^^^ reference local fails_139 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local f_143 +// ^ reference local f_143 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Failure#path. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathSeparator. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#max. + for (fail in fails) { +// ^^^^ definition local fail_144 +// ^^^^^ reference local fails_139 + let (path = fail.path.join(pathSeparator)) +// ^^^^ definition local path_145 +// ^^^^ reference local fail_144 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Failure#path. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathSeparator. + "\t'\(path)'\(" ".repeat(maxPathLength - path.length)): \(fail.message)" +// ^^^^ reference local path_145 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^^^^^^^^^ reference local maxPathLength_143 +// ^^^^ reference local path_145 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^ reference local fail_144 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Failure#message. + } + }.join("\n")) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + throw(msg) +// ^^^ reference local msg_141 + + local function findFailures(output: Mapping|Dynamic): List = +// ^^^^^^^^^^^^ definition local findFailures_151 +// ^^^^^^ definition local output_151 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Failure# + findFailureAcc.apply(List(), null, output) +// ^^^^^^^^^^^^^^ reference local findFailureAcc_154 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function3#apply(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^ reference local output_151 + + local findFailureAcc = (result, _, value) -> +// ^^^^^^^^^^^^^^ definition local findFailureAcc_154 +// ^^^^^^ definition local result_154 +// ^^^^^ definition local value_154 + if (value is Failure) result.add(value) +// ^^^^^ reference local value_154 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Failure# +// ^^^^^^ reference local result_154 +// ^^^^^ reference local value_154 + else if (value is Mapping|Dynamic) value.toMap().fold(result, findFailureAcc) +// ^^^^^ reference local value_154 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ reference local value_154 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#fold(). +// ^^^^^^ reference local result_154 +// ^^^^^^^^^^^^^^ reference local findFailureAcc_154 + else result +// ^^^^^^ reference local result_154 + + abstract class Failure { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Failure# + message: String +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Failure#message. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + path: List +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Failure#path. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + class ReadFailure extends Failure +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ReadFailure# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Failure# + class CoerceFailure extends Failure +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/CoerceFailure# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/Failure# + + local function ReadFail(path: List, msg: String) = let (_path = path ) new ReadFailure { +// ^^^^^^^^ definition local ReadFail_167 +// ^^^^ definition local path_167 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local msg_167 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local _path_167 +// ^^^^ reference local path_167 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ReadFailure# + message = msg +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/message. +// ^^^ reference local msg_167 + path = _path +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/path. +// ^^^^^ reference local _path_167 + } + + local function CoerceFail(path: List, msg: String) = let (_path = path ) new CoerceFailure { +// ^^^^^^^^^^ definition local CoerceFail_172 +// ^^^^ definition local path_172 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local msg_172 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local _path_172 +// ^^^^ reference local path_172 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/CoerceFailure# + message = msg +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/message. +// ^^^ reference local msg_172 + path = _path +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/path. +// ^^^^^ reference local _path_172 + } + + local function parseArraySyntax(input: String): Listing = new { +// ^^^^^^^^^^^^^^^^ definition local parseArraySyntax_177 +// ^^^^^ definition local input_177 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + when (input.startsWith("{") && input.endsWith("}")) { +// ^^^^^ reference local input_177 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^ reference local input_177 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#endsWith(). + ...input.drop(1).dropLast(1).split(",").map((e) -> e.trim()) +// ^^^^^ reference local input_177 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#dropLast(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local e_179 +// ^ reference local e_179 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#trim(). + } else { + input +// ^^^^^ reference local input_177 + } + } + + local function applyToDynamic(path, default: Dynamic) = +// ^^^^^^^^^^^^^^ definition local applyToDynamic_185 +// ^^^^ definition local path_185 +// ^^^^^^^ definition local default_185 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + if (default.toList().isEmpty && default.toMap().isEmpty) +// ^^^^^^^ reference local default_185 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^^^^^ reference local default_185 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#isEmpty. + // Do some special handling for empty dynamic objects + let (potentialValue = readValue(path)) +// ^^^^^^^^^^^^^^ definition local potentialValue_188 +// ^^^^^^^^^ reference local readValue_268 +// ^^^^ reference local path_185 + if (potentialValue is ReadFailure) +// ^^^^^^^^^^^^^^ reference local potentialValue_188 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ReadFailure# + default +// ^^^^^^^ reference local default_185 + else if (potentialValue is String) +// ^^^^^^^^^^^^^^ reference local potentialValue_188 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + parseArraySyntax(potentialValue) +// ^^^^^^^^^^^^^^^^ reference local parseArraySyntax_177 +// ^^^^^^^^^^^^^^ reference local potentialValue_188 + else + potentialValue ?? default +// ^^^^^^^^^^^^^^ reference local potentialValue_188 +// ^^^^^^^ reference local default_185 + else + new Mapping { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + for (name, defaultValue in default) { +// ^^^^ definition local name_197 +// ^^^^^^^^^^^^ definition local defaultValue_197 +// ^^^^^^^ reference local default_185 + when (defaultValue is Dynamic) { +// ^^^^^^^^^^^^ reference local defaultValue_197 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + [name] = applyToDynamic(path.add(name.toString()), defaultValue) +// ^^^^ reference local name_197 +// ^^^^^^^^^^^^^^ reference local applyToDynamic_185 +// ^^^^ reference local path_185 +// ^^^^ reference local name_197 +// ^^^^^^^^^^^^ reference local defaultValue_197 + } else { + [name] = let (_path = path.add(name.toString())) +// ^^^^ reference local name_197 +// ^^^^^ definition local _path_201 +// ^^^^ reference local path_185 +// ^^^^ reference local name_197 + let (potentialValue = coerceInput(readValue(_path), defaultValue.getClass(), _path)) +// ^^^^^^^^^^^^^^ definition local potentialValue_202 +// ^^^^^^^^^^^ reference local coerceInput_235 +// ^^^^^^^^^ reference local readValue_268 +// ^^^^^ reference local _path_201 +// ^^^^^^^^^^^^ reference local defaultValue_197 +// ^^^^^ reference local _path_201 + if (potentialValue is ReadFailure) +// ^^^^^^^^^^^^^^ reference local potentialValue_202 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ReadFailure# + defaultValue +// ^^^^^^^^^^^^ reference local defaultValue_197 + else + potentialValue +// ^^^^^^^^^^^^^^ reference local potentialValue_202 + } + } + }.toMap().toDynamic() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toDynamic(). + + hidden classHandlers: Mapping Any> = new { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/classHandlers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + [Int] = (value) -> +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^^ definition local value_212 + value.toIntOrNull() +// ^^^^^ reference local value_212 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toIntOrNull(). + + [String] = (value) -> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local value_215 + value +// ^^^^^ reference local value_215 + + [Float] = (value) -> +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# +// ^^^^^ definition local value_218 + value.toFloatOrNull() +// ^^^^^ reference local value_218 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toFloatOrNull(). + + [Number] = (value) -> +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^ definition local value_221 + value.toIntOrNull() ?? value.toFloatOrNull() +// ^^^^^ reference local value_221 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toIntOrNull(). +// ^^^^^ reference local value_221 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toFloatOrNull(). + + [Boolean] = (value) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^ definition local value_224 + value.toBooleanOrNull() +// ^^^^^ reference local value_224 +// ^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toBooleanOrNull(). + + [Null] = (_) -> throw(""" +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# + Unable to perform structured read due to ambiguous type in schema. + This is normally caused by a schema property having default value of `null`, and no type signature. + """) + + [Resource] = (value) -> value +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource# +// ^^^^^ definition local value_232 +// ^^^^^ reference local value_232 + } + + local function coerceInput(value: String?|Resource?, clazz: Class|TypeAlias, path:List) = +// ^^^^^^^^^^^ definition local coerceInput_235 +// ^^^^^ definition local value_235 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource# +// ^^^^^ definition local clazz_235 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# +// ^^^^ definition local path_235 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (clazz is TypeAlias) coerceInput(value, reflect.TypeAlias(clazz).referent.referent.reflectee, path) +// ^^^^^ reference local clazz_235 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/TypeAlias# +// ^^^^^^^^^^^ reference local coerceInput_235 +// ^^^^^ reference local value_235 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias(). +// ^^^^^ reference local clazz_235 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeAlias#referent. +// ^^^^ reference local path_235 + else if (!classHandlers.containsKey(clazz)) applyToClass(clazz, path) +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/classHandlers. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#containsKey(). +// ^^^^^ reference local clazz_235 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/applyToClass(). +// ^^^^^ reference local clazz_235 +// ^^^^ reference local path_235 + else if (value is String) +// ^^^^^ reference local value_235 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + classHandlers[clazz].apply(value) ?? CoerceFail(path, "Unable to coerce '\(value)' into type \(clazz.simpleName)") +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/classHandlers. +// ^^^^^ reference local clazz_235 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^ reference local value_235 +// ^^^^^^^^^^ reference local CoerceFail_172 +// ^^^^ reference local path_235 +// ^^^^^ reference local value_235 +// ^^^^^ reference local clazz_235 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + else + value ?? ReadFail( +// ^^^^^ reference local value_235 +// ^^^^^^^^ reference local ReadFail_167 + path, +// ^^^^ reference local path_235 + "Not provided. Make sure you pass the argument '-p \(path.join(pathSeparator))=<\(clazz.simpleName)>' to pkl eval" +// ^^^^ reference local path_235 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathSeparator. +// ^^^^^ reference local clazz_235 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. + ) + + + local function readValueToTarget(path: List, name: String, target: reflect.Property): Any? = +// ^^^^^^^^^^^^^^^^^ definition local readValueToTarget_247 +// ^^^^ definition local path_247 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ definition local name_247 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ definition local target_247 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + let (path = path.add(name)) +// ^^^^ definition local path_248 +// ^^^^ reference local path_247 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^ reference local name_247 + let (clazz = +// ^^^^^ definition local clazz_249 + if (target.type is reflect.UnknownType) +// ^^^^^^ reference local target_247 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/UnknownType# + target.defaultValue.getClass() +// ^^^^^^ reference local target_247 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#defaultValue. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + else if (target.type is reflect.NullableType) +// ^^^^^^ reference local target_247 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType# + let (_type = target.type as reflect.NullableType) +// ^^^^^ definition local _type_253 +// ^^^^^^ reference local target_247 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType# + _type.member.referent.reflectee +// ^^^^^ reference local _type_253 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/NullableType#member. + else if (target.type is reflect.DeclaredType) +// ^^^^^^ reference local target_247 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# + let (_type = target.type as reflect.DeclaredType) +// ^^^^^ definition local _type_256 +// ^^^^^^ reference local target_247 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#type. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType# + _type.referent.reflectee +// ^^^^^ reference local _type_256 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/DeclaredType#referent. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/TypeDeclaration#reflectee. + else + null + ) + if (clazz == Dynamic) +// ^^^^^ reference local clazz_249 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + applyToDynamic(path, target.defaultValue) +// ^^^^^^^^^^^^^^ reference local applyToDynamic_185 +// ^^^^ reference local path_248 +// ^^^^^^ reference local target_247 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Property#defaultValue. + else if (clazz != null) +// ^^^^^ reference local clazz_249 + coerceInput(readValue(path), clazz, path) +// ^^^^^^^^^^^ reference local coerceInput_235 +// ^^^^^^^^^ reference local readValue_268 +// ^^^^ reference local path_248 +// ^^^^^ reference local clazz_249 +// ^^^^ reference local path_248 + else + null + + local function readValue(path: List) = readFunc.apply(pathTemplate.apply(path)) +// ^^^^^^^^^ definition local readValue_268 +// ^^^^ definition local path_268 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/readFunc. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/pathTemplate. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^ reference local path_268 diff --git a/pkl-pantrysnapshot/pkl.experimental.structuredRead/tests/dynamicType.pkl b/pkl-pantrysnapshot/pkl.experimental.structuredRead/tests/dynamicType.pkl new file mode 100755 index 00000000..cce7fde3 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.structuredRead/tests/dynamicType.pkl @@ -0,0 +1,129 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.structuredRead.tests.dynamicType +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/ + amends "pkl:test" + + import ".../structuredRead.pkl" + + local function testHarness(name: String, value: String) = (structuredRead.fromExternalProps) { +// ^^^^^^^^^^^ definition local testHarness_21 +// ^^^^ definition local name_21 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local value_21 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fromExternalProps. + local responses = Map(name, value) +// ^^^^^^^^^ definition local responses_22 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^ reference local name_21 +// ^^^^^ reference local value_21 + readFunc = (s:String) -> responses.getOrNull(s.replaceFirst(inputScheme, "")) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/readFunc. +// ^ definition local s_23 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference local responses_22 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#getOrNull(). +// ^ reference local s_23 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. + } + + + local class DynamicValues { +// ^^^^^^^^^^^^^ definition local DynamicValues_27 + TestInput { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/DynamicValues#TestInput. + Nested = "String" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/DynamicValues#Nested. + } + } + + local class NestedDynamic { +// ^^^^^^^^^^^^^ definition local NestedDynamic_33 + Layer1 { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/NestedDynamic#Layer1. + Layer2 { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/NestedDynamic#Layer2. + Layer3 { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/NestedDynamic#Layer3. + TestValue = 40 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/NestedDynamic#TestValue. + DefaultString = "Still here" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/NestedDynamic#DefaultString. + } + TestIntType = 32 +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/NestedDynamic#TestIntType. + } + DefaultInt = 42 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/NestedDynamic#DefaultInt. + } + } + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/examples. + ["dynamic types"] { + testHarness("TestInput.Nested", "A new string").fill(DynamicValues) +// ^^^^^^^^^^^ reference local testHarness_21 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^ reference local DynamicValues_27 + } + ["nested dynamic types"] { + testHarness("Layer1.Layer2.Layer3.TestValue", "999").fill(NestedDynamic) +// ^^^^^^^^^^^ reference local testHarness_21 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^ reference local NestedDynamic_33 + } + ["incorrect dynamic value"] { + module.catch(() -> testHarness("Layer1.Layer2.TestIntType", "String").fill(NestedDynamic)) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^^^^ reference local testHarness_21 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^ reference local NestedDynamic_33 + } + } + + local underTest = testHarness("Layer1.Layer2.Layer3.TestValue", "999").fill(NestedDynamic) as NestedDynamic +// ^^^^^^^^^ definition local underTest_57 +// ^^^^^^^^^^^ reference local testHarness_21 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^ reference local NestedDynamic_33 +// ^^^^^^^^^^^^^ reference local NestedDynamic_33 + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/facts. + ["incorrect type for dynamic property causes coerce error"] { + module.catch(() -> testHarness("Layer1.Layer2.TestIntType", "String").fill(NestedDynamic)).contains("coerce") +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^^^^ reference local testHarness_21 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^ reference local NestedDynamic_33 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + } + ["nested dynamic value set"] { + underTest.Layer1.Layer2.Layer3.TestValue == 999 +// ^^^^^^^^^ reference local underTest_57 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/NestedDynamic#Layer1. + } + ["nested dynamic default values preserved"] { + underTest.Layer1.Layer2.Layer3.DefaultString == "Still here" && +// ^^^^^^^^^ reference local underTest_57 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/NestedDynamic#Layer1. + underTest.Layer1.DefaultInt == 42 +// ^^^^^^^^^ reference local underTest_57 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/dynamicType.pkl`/NestedDynamic#Layer1. + } + } diff --git a/pkl-pantrysnapshot/pkl.experimental.structuredRead/tests/fixtures/TestStructure.pkl b/pkl-pantrysnapshot/pkl.experimental.structuredRead/tests/fixtures/TestStructure.pkl new file mode 100755 index 00000000..24184f20 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.structuredRead/tests/fixtures/TestStructure.pkl @@ -0,0 +1,79 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + test = "Hello" +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/test. + + other:Int +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/other. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + class DoubleNested { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/DoubleNested# + num: Int +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/DoubleNested#num. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + float: Float +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/DoubleNested#float. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + string: String +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/DoubleNested#string. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + nullable: Number? +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/DoubleNested#nullable. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + hasDefault = 23.3 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/DoubleNested#hasDefault. + } + + class Thing { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/Thing# + stuff: Boolean +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/Thing#stuff. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + nested: DoubleNested +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/Thing#nested. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/DoubleNested# + } + + t:Thing +//^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/t. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/Thing# + + typealias Stuff = String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/Stuff# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + c:Stuff +//^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/c. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/Stuff# + + number:Number +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/number. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + secondNumber: Number +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/secondNumber. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + + float: Float +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/float. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + secondFloat: Float +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/secondFloat. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + + nullableWithDefault: Int? = 10 +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/nullableWithDefault. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# diff --git a/pkl-pantrysnapshot/pkl.experimental.structuredRead/tests/structuredRead.pkl b/pkl-pantrysnapshot/pkl.experimental.structuredRead/tests/structuredRead.pkl new file mode 100755 index 00000000..79ff88ba --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.structuredRead/tests/structuredRead.pkl @@ -0,0 +1,397 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.structuredRead.tests.structuredRead +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/ + amends "pkl:test" + + import "fixtures/TestStructure.pkl" + import "../structuredRead.pkl" + + local extProps = structuredRead.fromExternalProps +// ^^^^^^^^ definition local extProps_22 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fromExternalProps. + local env = structuredRead.fromEnv +// ^^^ definition local env_23 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fromEnv. + local https = structuredRead.fromHttps +// ^^^^^ definition local https_24 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fromHttps. + + local function testHarness(name: String, value: String) = new Mixin { +// ^^^^^^^^^^^ definition local testHarness_26 +// ^^^^ definition local name_26 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local value_26 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mixin# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/ + local responses = Map(name, value) +// ^^^^^^^^^ definition local responses_27 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^ reference local name_26 +// ^^^^^ reference local value_26 + readFunc = (s:String) -> responses.getOrNull(s.replaceFirst(inputScheme, "")) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/readFunc. +// ^ definition local s_28 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference local responses_27 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#getOrNull(). +// ^ reference local s_28 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. + } + + local testValues = new Mapping { +// ^^^^^^^^^^ definition local testValues_31 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["test"] = "string" + ["other"] = "123123" + ["c"] = "afe" + ["t.stuff"] = "TRUE" + ["t.nested.num"] = "23" + ["t.nested.float"] = "23" + ["t.nested.string"] = "AFWFAWEf" + ["number"] = "234234" + ["secondNumber"] = "342.023" + ["float"] = "20.0" + ["secondFloat"] = "23" + } + + local allNulls = (extProps) { +// ^^^^^^^^ definition local allNulls_45 +// ^^^^^^^^ reference local extProps_22 + readFunc = (s) -> null +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/readFunc. +// ^ definition local s_46 + } + + local topLevelProvided = (extProps) { +// ^^^^^^^^^^^^^^^^ definition local topLevelProvided_49 +// ^^^^^^^^ reference local extProps_22 + local responses = new Mapping { +// ^^^^^^^^^ definition local responses_50 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["test"] = "string" + ["other"] = "12312" + ["c"] = "afe" + }.toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + readFunc = (s:String) -> responses.getOrNull(s.replaceFirst(inputScheme, "")) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/readFunc. +// ^ definition local s_55 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference local responses_50 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#getOrNull(). +// ^ reference local s_55 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. + } + + local incorrectTypes = (extProps) { +// ^^^^^^^^^^^^^^ definition local incorrectTypes_58 +// ^^^^^^^^ reference local extProps_22 + local responses = new Mapping { +// ^^^^^^^^^ definition local responses_59 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["test"] = "string" + ["other"] = "this should be an int" + ["c"] = "afe" + ["t.stuff"] = "Should be a bool" + }.toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + readFunc = (s:String) -> responses.getOrNull(s.replaceFirst(inputScheme, "")) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/readFunc. +// ^ definition local s_65 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference local responses_59 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#getOrNull(). +// ^ reference local s_65 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. + } + + local correctInput = (extProps) { +// ^^^^^^^^^^^^ definition local correctInput_68 +// ^^^^^^^^ reference local extProps_22 + local responses = testValues.toMap() +// ^^^^^^^^^ definition local responses_69 +// ^^^^^^^^^^ reference local testValues_31 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + readFunc = (s:String) -> responses.getOrNull(s.replaceFirst(inputScheme, "")) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/readFunc. +// ^ definition local s_70 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference local responses_69 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#getOrNull(). +// ^ reference local s_70 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. + } + + local correctEnvVars = (extProps) { +// ^^^^^^^^^^^^^^ definition local correctEnvVars_73 +// ^^^^^^^^ reference local extProps_22 + local responses = new Mapping { +// ^^^^^^^^^ definition local responses_74 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["test"] = "string" + ["other"] = "123123" + ["c"] = "afe" + ["t_stuff"] = "TRUE" + ["t_nested_num"] = "12" + ["t_nested_float"] = "23.3" + ["t_nested_string"] = "afwf" + ["number"] = "234234" + ["secondNumber"] = "342.023" + ["float"] = "20.0" + ["secondFloat"] = "23" + }.toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + pathSeparator = "_" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/pathSeparator. + inputScheme = "env:" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/inputScheme. + + readFunc = (s:String) -> responses.getOrNull(s.replaceFirst(inputScheme, "")) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/readFunc. +// ^ definition local s_90 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference local responses_74 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#getOrNull(). +// ^ reference local s_90 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/inputScheme. + } + + local incorrectNullableType = (extProps) { +// ^^^^^^^^^^^^^^^^^^^^^ definition local incorrectNullableType_93 +// ^^^^^^^^ reference local extProps_22 + local responses = (testValues) { +// ^^^^^^^^^ definition local responses_94 +// ^^^^^^^^^^ reference local testValues_31 + ["nullableWithDefault"] = "Should be an int" + } + readFunc = (s:String) -> responses.getOrNull(s.replaceFirst(inputScheme, "")) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/readFunc. +// ^ definition local s_97 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference local responses_94 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^ reference local s_97 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceFirst(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/inputScheme. + } + + local class EnvConfig { +// ^^^^^^^^^ definition local EnvConfig_100 + SHELL: String? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/EnvConfig#SHELL. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + USER: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/EnvConfig#USER. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + PWD: String? +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/EnvConfig#PWD. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + LANG: String? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/EnvConfig#LANG. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + local Http = new Dynamic { +// ^^^^ definition local Http_107 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + `raw.githubusercontent.com/apple/pkl-pantry` { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/`raw.githubusercontent.com/apple/pkl-pantry`. + `8fcea0e535d2eb473545305d8a573144f2b0d33d` { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/8fcea0e535d2eb473545305d8a573144f2b0d33d. + `README.adoc` {} +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/`README.adoc`. + `CONTRIBUTING.adoc` {} +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/`CONTRIBUTING.adoc`. + } + } + } + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/examples. + ["missing properties"] { + module.catch(() -> allNulls.fill(TestStructure)) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference local allNulls_45 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/ + } + ["top level provided properties"] { + module.catch(() -> topLevelProvided.fill(TestStructure)) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^^^^^^^^^ reference local topLevelProvided_49 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/ + } + ["incorrect types"] { + module.catch(() -> incorrectTypes.fill(TestStructure)) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^^^^^^^ reference local incorrectTypes_58 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/ + } + ["incorrect nullable type"] { + module.catch(() -> incorrectNullableType.fill(TestStructure)) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^^^^^^^^^^^^^^ reference local incorrectNullableType_93 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/ + } + ["correct input"] { + correctInput.fill(TestStructure) +// ^^^^^^^^^^^^ reference local correctInput_68 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/ + } + ["correct env type input"] { + correctEnvVars.fill(TestStructure) +// ^^^^^^^^^^^^^^ reference local correctEnvVars_73 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/fixtures/TestStructure.pkl`/ + } + ["load from enviroment"] { + (env |> testHarness("SHELL", "zsh")).fill(EnvConfig) +// ^^^ reference local env_23 +// ^^^^^^^^^^^ reference local testHarness_26 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^ reference local EnvConfig_100 + } + ["load from https"] { + https.fill(Http) +// ^^^^^ reference local https_24 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^ reference local Http_107 + } + } + + local class NullableTypeWithDefault { +// ^^^^^^^^^^^^^^^^^^^^^^^ definition local NullableTypeWithDefault_143 + TestInput: Boolean? = true +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/NullableTypeWithDefault#TestInput. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + } + + local class TypedWithDefaults { +// ^^^^^^^^^^^^^^^^^ definition local TypedWithDefaults_147 + TestInput: Int = 10 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/TypedWithDefaults#TestInput. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + } + + local class TypelessWithDefault { +// ^^^^^^^^^^^^^^^^^^^ definition local TypelessWithDefault_151 + TestInput = 20.0 +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/TypelessWithDefault#TestInput. + } + + local class NullValueProperty { +// ^^^^^^^^^^^^^^^^^ definition local NullValueProperty_155 + TestInput = null +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/NullValueProperty#TestInput. + } + + local class DynamicList { +// ^^^^^^^^^^^ definition local DynamicList_159 + TestInput { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/DynamicList#TestInput. + 123 + } + } + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/facts. + ["incorrect type for nullable with default still results in coerce error"] { + module.catch(() -> (extProps |> testHarness("TestInput", "not a bool")).fill(NullableTypeWithDefault)).contains("coerce") +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference local extProps_22 +// ^^^^^^^^^^^ reference local testHarness_26 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local NullableTypeWithDefault_143 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + } + ["incorrect type for typed prop with default still results in coerce error"] { + module.catch(() -> (extProps |> testHarness("TestInput", "not an int")).fill(TypedWithDefaults)).contains("coerce") +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference local extProps_22 +// ^^^^^^^^^^^ reference local testHarness_26 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^^^^^ reference local TypedWithDefaults_147 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + } + ["incorrect type for un-typed prop with default still results in coerce error"] { + module.catch(() -> (extProps |> testHarness("TestInput", "not a float")).fill(TypelessWithDefault)).contains("coerce") +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference local extProps_22 +// ^^^^^^^^^^^ reference local testHarness_26 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^^^^^^^ reference local TypelessWithDefault_151 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + } + ["un-typed null property causes failure"] { + module.catch(() -> (extProps |> testHarness("TestInput", "9999")).fill(NullValueProperty)).contains("ambiguous type") +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference local extProps_22 +// ^^^^^^^^^^^ reference local testHarness_26 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^^^^^ reference local NullValueProperty_155 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + } + ["incorrect type in dynamic list type"] { + module.catch(() -> (extProps |> testHarness("TestInput.0", "not an int")).fill(DynamicList)).contains("coerce") +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference local extProps_22 +// ^^^^^^^^^^^ reference local testHarness_26 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^ reference local DynamicList_159 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + } + ["nullable with default inherits default value"] { + ((extProps |> testHarness("", "")).fill(NullableTypeWithDefault) as NullableTypeWithDefault).TestInput == true +// ^^^^^^^^ reference local extProps_22 +// ^^^^^^^^^^^ reference local testHarness_26 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local NullableTypeWithDefault_143 +// ^^^^^^^^^^^^^^^^^^^^^^^ reference local NullableTypeWithDefault_143 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/NullableTypeWithDefault#TestInput. + } + ["typed prop with default inherits default value"] { + ((extProps |> testHarness("", "")).fill(TypedWithDefaults) as TypedWithDefaults).TestInput == 10 +// ^^^^^^^^ reference local extProps_22 +// ^^^^^^^^^^^ reference local testHarness_26 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^^^^^ reference local TypedWithDefaults_147 +// ^^^^^^^^^^^^^^^^^ reference local TypedWithDefaults_147 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/TypedWithDefaults#TestInput. + } + ["un-typed prop with default still coerces correctly"] { + ((extProps |> testHarness("TestInput", "9999")).fill(TypelessWithDefault) as TypelessWithDefault).TestInput == 9999 +// ^^^^^^^^ reference local extProps_22 +// ^^^^^^^^^^^ reference local testHarness_26 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `structuredRead.pkl`/fill(). +// ^^^^^^^^^^^^^^^^^^^ reference local TypelessWithDefault_151 +// ^^^^^^^^^^^^^^^^^^^ reference local TypelessWithDefault_151 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.structuredRead 1.0.4 `tests/structuredRead.pkl`/TypelessWithDefault#TestInput. + } + } diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/AnnotationNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/AnnotationNode.pkl new file mode 100755 index 00000000..bbe11d4f --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/AnnotationNode.pkl @@ -0,0 +1,46 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.AnnotationNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/ + + extends "Node.pkl" + + import "QualifiedIdentifierNode.pkl" + import "ObjectBodyNode.pkl" + + identifier: QualifiedIdentifierNode +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/identifier. +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `QualifiedIdentifierNode.pkl`/ + + body: ObjectBodyNode? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/body. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + + function render(currentIndent: String) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/render(). +// ^^^^^^^^^^^^^ definition local currentIndent_27 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + "\(currentIndent)@\(identifier.render(currentIndent))" + +// ^^^^^^^^^^^^^ reference local currentIndent_27 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/identifier. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `QualifiedIdentifierNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_27 + if (body == null) "" else " " + body.render(currentIndent) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/body. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/body. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_27 + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/ClassNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/ClassNode.pkl new file mode 100755 index 00000000..eacd9403 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/ClassNode.pkl @@ -0,0 +1,127 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.ClassNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ + + extends "ClassOrModuleNode.pkl" + + import "Node.pkl" + import "IdentifierNode.pkl" + import "AnnotationNode.pkl" + import "DocCommentNode.pkl" + import "TypeNode.pkl" + + docComment: DocCommentNode? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/docComment. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/ + + annotations: Listing? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/annotations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/ + + classHeader: ClassHeader +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/classHeader. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassHeader# + + class ClassHeader extends Node { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassHeader# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + modifiers: Listing<"abstract"|"external"|"local"|"open">(isDistinct)? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassHeader#modifiers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. + name: IdentifierNode +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassHeader#name. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/ + extendsClause: ClassExtendsClause? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassHeader#extendsClause. +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassExtendsClause# + + function render(currentIndent: String) = currentIndent + new Listing { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassHeader#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_37 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^ reference local currentIndent_37 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + modifiers?.join(" ") +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassHeader#modifiers. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + "class \(name.render(currentIndent))" +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassHeader#name. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_37 + extendsClause?.render(currentIndent) +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassHeader#extendsClause. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassExtendsClause#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_37 + "{" + }.toList().filterNonNull().join(" ") +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + + class ClassExtendsClause extends Node { +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassExtendsClause# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + type: TypeNode.DeclaredTypeNode +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassExtendsClause#type. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + + function render(currentIndent: String) = "extends " + type.render(currentIndent) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassExtendsClause#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_48 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassExtendsClause#type. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_48 + } + + function render(currentIndent: String) = List( +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/render(). +// ^^^^^^^^^^^^^ definition local currentIndent_51 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + docComment?.render(currentIndent), +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/docComment. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_51 + annotations?.toList()?.map((a) -> a.render(currentIndent))?.join("\n"), +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/annotations. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local a_53 +// ^ reference local a_53 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_51 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + classHeader.render(currentIndent), +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/classHeader. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ClassHeader#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_51 + super.render(currentIndent + indent), +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_51 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/indent. + "\(currentIndent)}" +// ^^^^^^^^^^^^^ reference local currentIndent_51 + ) + .filterNonNull() +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). + .join("\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/ClassOrModuleNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/ClassOrModuleNode.pkl new file mode 100755 index 00000000..4d70119a --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/ClassOrModuleNode.pkl @@ -0,0 +1,333 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + abstract module pkl.experimental.syntax.ClassOrModuleNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/ + + extends "Node.pkl" + + import "Node.pkl" + import "DocCommentNode.pkl" + import "AnnotationNode.pkl" + import "ExpressionNode.pkl" + import "TypeAnnotationNode.pkl" + import "IdentifierNode.pkl" + import "ObjectBodyNode.pkl" + import "ParameterNode.pkl" + + /// The properties as defined in the class or module. + properties: Listing? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/properties. +//documentation +//> The properties as defined in the class or module. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode# + + /// The methods as defined in the class or module. + methods: Listing? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/methods. +//documentation +//> The methods as defined in the class or module. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode# + + /// A node representing the definition of a new property. + class PropertyDefinitionNode extends Node { +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode# +// documentation +// > A node representing the definition of a new property. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + docComment: DocCommentNode? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#docComment. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/ + annotations: Listing? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#annotations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/ + modifiers: Listing<"abstract"|"const"|"external"|"fixed"|"hidden"|"local">(isDistinct)? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#modifiers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. + name: IdentifierNode +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#name. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/ + typeAnnotation: TypeAnnotationNode? +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#typeAnnotation. +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAnnotationNode.pkl`/ + + defaultValue: ExpressionNode? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#defaultValue. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + /// The object body for a property definition. + /// + /// * `foo: Bar { ... }` is invalid syntax. + /// * `foo = myBar { ... }` is technically valid syntax but should be acheived using an amends expression node. + objectBody: ObjectBodyNode(typeAnnotation == null && defaultValue == null)? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#objectBody. +// documentation +// > The object body for a property definition. +// > +// > * `foo: Bar { ... }` is invalid syntax. +// > * `foo = myBar { ... }` is technically valid syntax but should be acheived using an amends expression node. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#typeAnnotation. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#defaultValue. + + local function renderPropertyLine(currentIndent: String) = currentIndent + List( +// ^^^^^^^^^^^^^^^^^^ definition local renderPropertyLine_51 +// ^^^^^^^^^^^^^ definition local currentIndent_51 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^ reference local currentIndent_51 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + if (modifiers != null) modifiers.join(" ") + " " else null, +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#modifiers. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#modifiers. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + name.render(currentIndent), +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#name. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_51 + typeAnnotation?.render(currentIndent), +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#typeAnnotation. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAnnotationNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_51 + if (defaultValue != null) " = " + defaultValue.render(currentIndent) else null, +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#defaultValue. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#defaultValue. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_51 + if (objectBody != null) " " + objectBody.render(currentIndent) else null +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#objectBody. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#objectBody. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_51 + ).filterNonNull().join("") +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + function render(currentIndent: String) = List( +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_59 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + docComment?.render(currentIndent), +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#docComment. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_59 + annotations?.toList()?.map((a) -> a.render(currentIndent))?.join("\n"), +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#annotations. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local a_61 +// ^ reference local a_61 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_59 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + renderPropertyLine(currentIndent) +// ^^^^^^^^^^^^^^^^^^ reference local renderPropertyLine_51 +// ^^^^^^^^^^^^^ reference local currentIndent_59 + ) + .filter((it) -> it != null && !it.isEmpty) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filter(). +// ^^ definition local it_64 +// ^^ reference local it_64 +// ^^ reference local it_64 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. + .join("\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + + class MethodNode extends Node { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + docComment: DocCommentNode? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#docComment. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/ + annotations: Listing? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#annotations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/ + modifiers: Listing<"abstract"|"const"|"external"|"local">(isDistinct)? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#modifiers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. + name: IdentifierNode +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#name. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/ + // TODO typeParameters? + parameters: Listing +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#parameters. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/ + returnTypeAnnotation: TypeAnnotationNode? +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#returnTypeAnnotation. +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAnnotationNode.pkl`/ + body: ExpressionNode +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#body. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + local function renderMethodHeader(currentIndent: String) = List( +// ^^^^^^^^^^^^^^^^^^ definition local renderMethodHeader_78 +// ^^^^^^^^^^^^^ definition local currentIndent_78 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + currentIndent, +// ^^^^^^^^^^^^^ reference local currentIndent_78 + if (modifiers != null) modifiers.join(" ") + " " else null, +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#modifiers. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#modifiers. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + "function ", + name.render(currentIndent), +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#name. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_78 + "(", + parameters?.toList()?.map((p) -> p.render(currentIndent)).join(", "), +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#parameters. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local p_84 +// ^ reference local p_84 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_78 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + ")", + returnTypeAnnotation?.render(currentIndent), +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#returnTypeAnnotation. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAnnotationNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_78 + " =" + ).filterNonNull().join("") +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + function renderMethodBody(currentIndent: String) = +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#renderMethodBody(). +// ^^^^^^^^^^^^^ definition local currentIndent_90 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (header = renderMethodHeader(currentIndent)) +// ^^^^^^ definition local header_91 +// ^^^^^^^^^^^^^^^^^^ reference local renderMethodHeader_78 +// ^^^^^^^^^^^^^ reference local currentIndent_90 + let (inlineBody = body.render(currentIndent)) +// ^^^^^^^^^^ definition local inlineBody_92 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#body. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_90 + let (firstInlineBodyLine = inlineBody.takeWhile((it) -> !it.endsWith("\n"))) +// ^^^^^^^^^^^^^^^^^^^ definition local firstInlineBodyLine_93 +// ^^^^^^^^^^ reference local inlineBody_92 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#takeWhile(). +// ^^ definition local it_93 +// ^^ reference local it_93 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#endsWith(). + if ("\(header) \(firstInlineBodyLine)".length <= maxColumnWidth) +// ^^^^^^ reference local header_91 +// ^^^^^^^^^^^^^^^^^^^ reference local firstInlineBodyLine_93 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/maxColumnWidth. + "\(header) \(inlineBody)" +// ^^^^^^ reference local header_91 +// ^^^^^^^^^^ reference local inlineBody_92 + else + "\(header)\n\(currentIndent + indent)\(body.render(currentIndent + indent))" +// ^^^^^^ reference local header_91 +// ^^^^^^^^^^^^^ reference local currentIndent_90 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/indent. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#body. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_90 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/indent. + + function render(currentIndent: String) = List( +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_99 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + docComment?.render(currentIndent), +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#docComment. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_99 + annotations?.toList()?.map((a) -> a.render(currentIndent))?.join("\n"), +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#annotations. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local a_101 +// ^ reference local a_101 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_99 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + renderMethodBody(currentIndent) +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#renderMethodBody(). +// ^^^^^^^^^^^^^ reference local currentIndent_99 + ) + .filter((it) -> it != null && !it.isEmpty) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filter(). +// ^^ definition local it_104 +// ^^ reference local it_104 +// ^^ reference local it_104 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. + .join("\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + + function renderProperties(currentIndent: String) = properties +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/renderProperties(). +// ^^^^^^^^^^^^^ definition local currentIndent_108 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/properties. + ?.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + ?.map((p) -> p.render(currentIndent)) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local p_110 +// ^ reference local p_110 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_108 + ?.join("\n\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + function renderMethods(currentIndent: String) = methods +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/renderMethods(). +// ^^^^^^^^^^^^^ definition local currentIndent_113 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/methods. + ?.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + ?.map((m) -> m.render(currentIndent)) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local m_115 +// ^ reference local m_115 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/MethodNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_113 + ?.join("\n\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + function render(currentIndent: String) = List(renderProperties(currentIndent), renderMethods(currentIndent)) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/render(). +// ^^^^^^^^^^^^^ definition local currentIndent_118 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/renderProperties(). +// ^^^^^^^^^^^^^ reference local currentIndent_118 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/renderMethods(). +// ^^^^^^^^^^^^^ reference local currentIndent_118 + .filterNonNull() +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). + .join("\n\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/DocCommentNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/DocCommentNode.pkl new file mode 100755 index 00000000..2a20ea65 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/DocCommentNode.pkl @@ -0,0 +1,212 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.DocCommentNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/ + + extends "Node.pkl" + + /// The doc comment itself, without the comment tokens (`///`). + value: String +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/value. +//documentation +//> The doc comment itself, without the comment tokens (`///`). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + local function wrapTextImpl(words: List, width: Int) = +// ^^^^^^^^^^^^ definition local wrapTextImpl_23 +// ^^^^^ definition local words_23 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local width_23 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + words.fold(Pair("", ""), (pair, word) -> +// ^^^^^ reference local words_23 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^ definition local pair_24 +// ^^^^ definition local word_24 + let (result: String = pair.first) +// ^^^^^^ definition local result_25 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference local pair_24 + let (currentLine: String = pair.second) +// ^^^^^^^^^^^ definition local currentLine_26 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference local pair_24 + if (currentLine.length + word.length > width) +// ^^^^^^^^^^^ reference local currentLine_26 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^ reference local word_24 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^ reference local width_23 + Pair( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). + if (result == "") currentLine +// ^^^^^^ reference local result_25 +// ^^^^^^^^^^^ reference local currentLine_26 + else result + "\n" + currentLine, +// ^^^^^^ reference local result_25 +// ^^^^^^^^^^^ reference local currentLine_26 + word +// ^^^^ reference local word_24 + ) + else + Pair( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). + result, +// ^^^^^^ reference local result_25 + if (currentLine == "") word +// ^^^^^^^^^^^ reference local currentLine_26 +// ^^^^ reference local word_24 + else currentLine + " " + word +// ^^^^^^^^^^^ reference local currentLine_26 +// ^^^^ reference local word_24 + ) + ) + + /// Wrap [text] at the specified column [width]. + local function wrapParagraph(text: String, width: Int) = +// ^^^^^^^^^^^^^ definition local wrapParagraph_41 +// documentation +// > Wrap [`text`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.syntax/DocCommentNode.pkl#L42,C30) at the specified column [`width`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.syntax/DocCommentNode.pkl#L42,C44). +// ^^^^ definition local text_42 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local width_42 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + let (words = text.split(Regex("\\s+"))) +// ^^^^^ definition local words_43 +// ^^^^ reference local text_42 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + let (result = words.fold(Pair("", ""), (pair, word) -> +// ^^^^^^ definition local result_44 +// ^^^^^ reference local words_43 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^ definition local pair_44 +// ^^^^ definition local word_44 + let (aggregate: String = pair.first) +// ^^^^^^^^^ definition local aggregate_45 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference local pair_44 + let (currentLine: String = pair.second) +// ^^^^^^^^^^^ definition local currentLine_46 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference local pair_44 + if (currentLine.length + word.length > width) +// ^^^^^^^^^^^ reference local currentLine_46 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^ reference local word_44 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^ reference local width_42 + Pair( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). + if (aggregate == "") currentLine +// ^^^^^^^^^ reference local aggregate_45 +// ^^^^^^^^^^^ reference local currentLine_46 + else aggregate + "\n" + currentLine, +// ^^^^^^^^^ reference local aggregate_45 +// ^^^^^^^^^^^ reference local currentLine_46 + word +// ^^^^ reference local word_44 + ) + else + Pair( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). + aggregate, +// ^^^^^^^^^ reference local aggregate_45 + if (currentLine == "") word +// ^^^^^^^^^^^ reference local currentLine_46 +// ^^^^ reference local word_44 + else currentLine + " " + word +// ^^^^^^^^^^^ reference local currentLine_46 +// ^^^^ reference local word_44 + ) + )) + List(result.first, result.second).filter((elem) -> !elem.isEmpty).join("\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^ reference local result_44 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^^^^^^ reference local result_44 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filter(). +// ^^^^ definition local elem_60 +// ^^^^ reference local elem_60 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + local function wrapText(text: String, width: Int) = +// ^^^^^^^^ definition local wrapText_62 +// ^^^^ definition local text_62 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local width_62 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + let (paragraphs = text.split("\n\n")) +// ^^^^^^^^^^ definition local paragraphs_63 +// ^^^^ reference local text_62 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). + paragraphs +// ^^^^^^^^^^ reference local paragraphs_63 + .map((it) -> wrapParagraph(it, width)) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local it_65 +// ^^^^^^^^^^^^^ reference local wrapParagraph_41 +// ^^ reference local it_65 +// ^^^^^ reference local width_62 + .join("\n\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + /// Configures this node to wrap lines when rendering. + hidden autoWrap: Boolean = false +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/autoWrap. +// documentation +// > Configures this node to wrap lines when rendering. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + function render(currentIndent: String) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/render(). +// ^^^^^^^^^^^^^ definition local currentIndent_71 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (wrapped = +// ^^^^^^^ definition local wrapped_72 + if (autoWrap) wrapText(value, maxColumnWidth - currentIndent.length) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/autoWrap. +// ^^^^^^^^ reference local wrapText_62 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/value. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/maxColumnWidth. +// ^^^^^^^^^^^^^ reference local currentIndent_71 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + else value +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/value. + ) + wrapped +// ^^^^^^^ reference local wrapped_72 + .split("\n") +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). + .map((line) -> +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^ definition local line_78 + if (line.isEmpty) "\(currentIndent)///" +// ^^^^ reference local line_78 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. +// ^^^^^^^^^^^^^ reference local currentIndent_71 + else "\(currentIndent)/// \(line)" +// ^^^^^^^^^^^^^ reference local currentIndent_71 +// ^^^^ reference local line_78 + ) + .join("\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/ExpressionNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/ExpressionNode.pkl new file mode 100755 index 00000000..2bb75472 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/ExpressionNode.pkl @@ -0,0 +1,670 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + abstract module pkl.experimental.syntax.ExpressionNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + extends "Node.pkl" + + import "ExpressionNode.pkl" + import "ObjectBodyNode.pkl" + import "IdentifierNode.pkl" + import "TypeNode.pkl" + import "operators.pkl" + + typealias CompoundExpressionNode = BinaryOperatorExpressionNode|PrefixOperatorExpressionNode|IfElseExpressionNode +// ^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/CompoundExpressionNode# +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode# +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode# + + class BinaryOperatorExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + local precedences: Mapping = new { +// ^^^^^^^^^^^ definition local precedences_29 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BinaryOperator# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + [operators.MULTIPLY] = 1 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/MULTIPLY. + [operators.DIVIDE] = 1 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/DIVIDE. + [operators.INTEGER_DIVIDE] = 1 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/INTEGER_DIVIDE. + [operators.MODULO] = 1 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/MODULO. + [operators.PLUS] = 2 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/PLUS. + [operators.BINARY_MINUS] = 2 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BINARY_MINUS. + [operators.GREATER_THAN] = 3 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN. + [operators.LESS_THAN] = 3 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN. + [operators.GREATER_THAN_OR_EQUALS] = 3 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN_OR_EQUALS. + [operators.LESS_THAN_OR_EQUALS] = 3 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN_OR_EQUALS. + [operators.IS] = 4 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/IS. + [operators.AS] = 4 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/AS. + [operators.EQUALS] = 5 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/EQUALS. + [operators.NOT_EQUALS] = 5 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NOT_EQUALS. + [operators.AND] = 6 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/AND. + [operators.OR] = 7 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/OR. + [operators.PIPE] = 8 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/PIPE. + } + + local function hasHigherPrecedence(a: String, b: String) = precedences[a] >= precedences[b] +// ^^^^^^^^^^^^^^^^^^^ definition local hasHigherPrecedence_49 +// ^ definition local a_49 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^ definition local b_49 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^ reference local precedences_29 +// ^ reference local a_49 +// ^^^^^^^^^^^ reference local precedences_29 +// ^ reference local b_49 + + operator: operators.BinaryOperator +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#operator. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BinaryOperator# + + /// The right hand side of the expression + lhs: ExpressionNode +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#lhs. +// documentation +// > The right hand side of the expression +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + /// The left hand side of the expression + rhs: ExpressionNode +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#rhs. +// documentation +// > The left hand side of the expression +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + local function renderChild(child: ExpressionNode, currentIndent: String) = +// ^^^^^^^^^^^ definition local renderChild_59 +// ^^^^^ definition local child_59 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ +// ^^^^^^^^^^^^^ definition local currentIndent_59 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (rendered = child.render(currentIndent)) +// ^^^^^^^^ definition local rendered_60 +// ^^^^^ reference local child_59 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_59 + if ( + !(child is CompoundExpressionNode) +// ^^^^^ reference local child_59 +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/CompoundExpressionNode# + || child is BinaryOperatorExpressionNode && hasHigherPrecedence(operator, child.operator) +// ^^^^^ reference local child_59 +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# +// ^^^^^^^^^^^^^^^^^^^ reference local hasHigherPrecedence_49 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#operator. +// ^^^^^ reference local child_59 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#operator. + ) + rendered +// ^^^^^^^^ reference local rendered_60 + else + parenthesize(rendered) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/parenthesize(). +// ^^^^^^^^ reference local rendered_60 + + function render(currentIndent: String) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_69 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + "\(renderChild(lhs, currentIndent)) \(operator) \(renderChild(rhs, currentIndent))" +// ^^^^^^^^^^^ reference local renderChild_59 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#lhs. +// ^^^^^^^^^^^^^ reference local currentIndent_69 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#operator. +// ^^^^^^^^^^^ reference local renderChild_59 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#rhs. +// ^^^^^^^^^^^^^ reference local currentIndent_69 + } + + class BuiltInKeywordExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BuiltInKeywordExpressionNode# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + keyword: "this"|"outer"|"module" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BuiltInKeywordExpressionNode#keyword. + + function render(_) = keyword +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BuiltInKeywordExpressionNode#render(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BuiltInKeywordExpressionNode#keyword. + } + + /// Unary operators in the prefix position: "!" and "-". + class PrefixOperatorExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode# +// documentation +// > Unary operators in the prefix position: "!" and "-". +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + operator: operators.PrefixOperator +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode#operator. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/PrefixOperator# + + expression: ExpressionNode +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode#expression. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + function render(currentIndent: String) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_85 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (body = expression.render(currentIndent)) +// ^^^^ definition local body_86 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode#expression. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_85 + if (expression is CompoundExpressionNode) operator + parenthesize(body) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode#expression. +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/CompoundExpressionNode# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode#operator. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/parenthesize(). +// ^^^^ reference local body_86 + else operator + body +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode#operator. +// ^^^^ reference local body_86 + } + + /// Unary operators in the postfix position: "!!" + class PostfixOperatorExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PostfixOperatorExpressionNode# +// documentation +// > Unary operators in the postfix position: "!!" +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + operator: operators.PostfixOperator +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PostfixOperatorExpressionNode#operator. +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/PostfixOperator# + + expression: ExpressionNode +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PostfixOperatorExpressionNode#expression. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + function render(currentIndent: String) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PostfixOperatorExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_97 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (body = expression.render(currentIndent)) +// ^^^^ definition local body_98 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PostfixOperatorExpressionNode#expression. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_97 + if (expression is CompoundExpressionNode) parenthesize(body) + operator +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PostfixOperatorExpressionNode#expression. +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/CompoundExpressionNode# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/parenthesize(). +// ^^^^ reference local body_98 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PostfixOperatorExpressionNode#operator. + else body + operator +// ^^^^ reference local body_98 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PostfixOperatorExpressionNode#operator. + } + + class MemberAccessExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + identifier: IdentifierNode +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#identifier. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/ + + arguments: Listing? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#arguments. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + function renderArguments(currentIndent: String) = +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#renderArguments(). +// ^^^^^^^^^^^^^ definition local currentIndent_108 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (arguments == null) "" +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#arguments. + else + let (args = arguments.toList().map((arg) -> arg.render(currentIndent))) +// ^^^^ definition local args_111 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#arguments. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^ definition local arg_111 +// ^^^ reference local arg_111 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_108 + parenthesize(args.join(", ")) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/parenthesize(). +// ^^^^ reference local args_111 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + function render(currentIndent: String) = "\(identifier.render(currentIndent))\(renderArguments(currentIndent))" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_114 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#identifier. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_114 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#renderArguments(). +// ^^^^^^^^^^^^^ reference local currentIndent_114 + } + + /// Can either be an identifer or a function call. + /// + /// ``` + /// foo.bar + /// foo.bar() + /// ``` + class QualifiedMemberAccessExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode# +// documentation +// > Can either be an identifer or a function call. +// > +// > ``` +// > foo.bar +// > foo.bar() +// > ``` +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + lhs: ExpressionNode +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode#lhs. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + symbol: "."|"?." = "." +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode#symbol. + + rhs: MemberAccessExpressionNode +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode#rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + + local function renderLhs(currentIndent: String) = +// ^^^^^^^^^ definition local renderLhs_130 +// ^^^^^^^^^^^^^ definition local currentIndent_130 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (lhs is CompoundExpressionNode) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode#lhs. +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/CompoundExpressionNode# + parenthesize(lhs.render(currentIndent)) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/parenthesize(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode#lhs. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_130 + else lhs.render(currentIndent) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode#lhs. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_130 + + function render(currentIndent: String) = "\(renderLhs(currentIndent))\(symbol)\(rhs.render(currentIndent))" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_135 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference local renderLhs_130 +// ^^^^^^^^^^^^^ reference local currentIndent_135 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode#symbol. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode#rhs. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_135 + } + + class SuperAccessExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperAccessExpressionNode# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + rhs: MemberAccessExpressionNode +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperAccessExpressionNode#rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + + function render(currentIndent) = "super.\(rhs.render(currentIndent))" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperAccessExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_141 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperAccessExpressionNode#rhs. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_141 + } + + class SuperSubscriptExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperSubscriptExpressionNode# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + subscript: ExpressionNode +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperSubscriptExpressionNode#subscript. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + function render(currentIndent) = "super[\(subscript.render(currentIndent))]" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperSubscriptExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_147 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperSubscriptExpressionNode#subscript. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_147 + } + + class SubscriptExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + lhs: ExpressionNode +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode#lhs. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + subscript: ExpressionNode +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode#subscript. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + local function renderLhs(currentIndent: String) = +// ^^^^^^^^^ definition local renderLhs_155 +// ^^^^^^^^^^^^^ definition local currentIndent_155 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (lhs is CompoundExpressionNode) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode#lhs. +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/CompoundExpressionNode# + parenthesize(lhs.render(currentIndent)) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/parenthesize(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode#lhs. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_155 + else lhs.render(currentIndent) +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode#lhs. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_155 + + function render(currentIndent: String): String = "\(renderLhs(currentIndent))[\(subscript.render(currentIndent))]" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_160 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference local renderLhs_155 +// ^^^^^^^^^^^^^ reference local currentIndent_160 +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode#subscript. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_160 + } + + /// Node representing a literal value; e.g. `true` and `"hello"`. + class LiteralValueExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// documentation +// > Node representing a literal value; e.g. `true` and `"hello"`. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + value: String|Boolean|Number|Null +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode#value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# + + function render(_) = pcfRenderer.renderValue(value) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode#render(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/pcfRenderer. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer#renderValue(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode#value. + } + + /// Node representing `new { ... }` or `new Type { ... }`. + class ObjectExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ObjectExpressionNode# +// documentation +// > Node representing `new { ... }` or `new Type { ... }`. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + body: ObjectBodyNode +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ObjectExpressionNode#body. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + + type: TypeNode? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ObjectExpressionNode#type. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + + function render(currentIndent: String) = List( +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ObjectExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_176 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + "new", + type?.render(currentIndent), +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ObjectExpressionNode#type. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_176 + body.render(currentIndent) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ObjectExpressionNode#body. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_176 + ).filterNonNull().join(" ") +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + + /// `if (...) ... else ...` + /// + /// To express `else if`, [elseBranch] should also be an [IfElseExpressionNode]. + class IfElseExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode# +// documentation +// > `if (...) ... else ...` +// > +// > To express `else if`, [`elseBranch`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.syntax/ExpressionNode.pkl#L191,C3) should also be an [`IfElseExpressionNode`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.syntax/ExpressionNode.pkl#L186,C7). +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + condition: ExpressionNode +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#condition. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + ifBranch: ExpressionNode +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#ifBranch. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + elseBranch: ExpressionNode +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#elseBranch. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + function renderElseBranch(currentIndent: String) = +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#renderElseBranch(). +// ^^^^^^^^^^^^^ definition local currentIndent_193 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (elseBranch is IfElseExpressionNode) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#elseBranch. +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode# + "\(currentIndent)else \(elseBranch.render(currentIndent))" +// ^^^^^^^^^^^^^ reference local currentIndent_193 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#elseBranch. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_193 + else + """ + \(currentIndent)else +// ^^^^^^^^^^^^^ reference local currentIndent_193 + \(currentIndent + indent)\(elseBranch.render(currentIndent + indent)) +// ^^^^^^^^^^^^^ reference local currentIndent_193 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/indent. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#elseBranch. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_193 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/indent. + """ + + function render(currentIndent: String) = """ +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_202 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if \(parenthesize(condition.render(currentIndent))) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/parenthesize(). +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#condition. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_202 + \(currentIndent + indent)\(ifBranch.render(currentIndent)) +// ^^^^^^^^^^^^^ reference local currentIndent_202 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/indent. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#ifBranch. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_202 + \(renderElseBranch(currentIndent)) +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#renderElseBranch(). +// ^^^^^^^^^^^^^ reference local currentIndent_202 + """ + } + + class ImportExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ImportExpressionNode# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + value: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ImportExpressionNode#value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + keyword: "import"|"import*" = "import" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ImportExpressionNode#keyword. + + fixed stringLiteralNode: LiteralValueExpressionNode = new { value = outer.value } +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ImportExpressionNode#stringLiteralNode. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ImportExpressionNode#value. + + function render(currentIndent: String) = "\(keyword)(\(stringLiteralNode.render(currentIndent)))" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ImportExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_216 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ImportExpressionNode#keyword. +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ImportExpressionNode#stringLiteralNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_216 + } + + class ReadExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + value: ExpressionNode +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode#value. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + keyword: "read"|"read*"|"read?" = "read" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode#keyword. + + function render(currentIndent: String) = "\(keyword)(\(value.render(currentIndent)))" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_224 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode#keyword. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode#value. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_224 + } + + class TraceExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/TraceExpressionNode# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + value: ExpressionNode +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/TraceExpressionNode#value. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + function render(currentIndent: String) = "trace(\(value.render(currentIndent)))" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/TraceExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_230 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/TraceExpressionNode#value. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_230 + } + + /// Provides interpolation and multi-line strings that are not available using [LiteralValueExpressionNode]. + class StringExpressionNode extends ExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/StringExpressionNode# +// documentation +// > Provides interpolation and multi-line strings that are not available using [`LiteralValueExpressionNode`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.syntax/ExpressionNode.pkl#L164,C7). +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + isMultiLine: Boolean = false +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/StringExpressionNode#isMultiLine. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + stringParts: Listing +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/StringExpressionNode#stringParts. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + function renderStringContents(currentIndent: String) = new Listing { +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/StringExpressionNode#renderStringContents(). +// ^^^^^^^^^^^^^ definition local currentIndent_239 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + for (part in stringParts) { +// ^^^^ definition local part_240 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/StringExpressionNode#stringParts. + when (part is ExpressionNode) { +// ^^^^ reference local part_240 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + #"\("# + part.render(currentIndent) +// ^^^^ reference local part_240 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_239 + ")" + } else { + if (isMultiLine) part.replaceAll("\n", "\n\(currentIndent)") +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/StringExpressionNode#isMultiLine. +// ^^^^ reference local part_240 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). +// ^^^^^^^^^^^^^ reference local currentIndent_239 + else part.replaceAll("\n", "\\n") +// ^^^^ reference local part_240 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + } + } + }.join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + + function render(currentIndent: String) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/StringExpressionNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_252 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (!isMultiLine) #""\#(renderStringContents(currentIndent))""# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/StringExpressionNode#isMultiLine. +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/StringExpressionNode#renderStringContents(). +// ^^^^^^^^^^^^^ reference local currentIndent_252 + else + let (newIndent = currentIndent + indent) +// ^^^^^^^^^ definition local newIndent_255 +// ^^^^^^^^^^^^^ reference local currentIndent_252 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/indent. + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + "\"\"\"" + newIndent + renderStringContents(newIndent) +// ^^^^^^^^^ reference local newIndent_255 +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/StringExpressionNode#renderStringContents(). +// ^^^^^^^^^ reference local newIndent_255 + "\(newIndent)\"\"\"" +// ^^^^^^^^^ reference local newIndent_255 + }.join("\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/IdentifierNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/IdentifierNode.pkl new file mode 100755 index 00000000..e4572111 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/IdentifierNode.pkl @@ -0,0 +1,104 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A token representing a name. + /// + /// Identifiers get surrounded by backticks (`) if they conflict with a keyword, or if + /// they don't match the normal identifier pattern. + @Unlisted +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Unlisted# + module pkl.experimental.syntax.IdentifierNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/ + + extends "Node.pkl" + + /// The raw value of the identifier. + /// + /// It's not possible to encode a backtick into an identifier. + value: String(!contains("`")) +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/value. +//documentation +//> The raw value of the identifier. +//> +//> It's not possible to encode a backtick into an identifier. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + + local keywords: Set = new Listing { +// ^^^^^^^^ definition local keywords_30 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + "abstract" + "amends" + "as" + "case" + "class" + "const" + "delete" + "else" + "extends" + "external" + "false" + "final" + "fixed" + "for" + "function" + "hidden" + "if" + "import" + "in" + "is" + "let" + "local" + "module" + "new" + "nothing" + "null" + "open" + "out" + "outer" + "override" + "protected" + "read" + "record" + "super" + "switch" + "this" + "throw" + "trace" + "true" + "typealias" + "unknown" + "vararg" + "when" + }.toSet() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toSet(). + + function render(_) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/render(). + if (value.matches(Regex(#"[A-Za-z$_][A-Za-z\d$_]*"#)) && !keywords.contains(value)) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/value. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^ reference local keywords_30 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#contains(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/value. + value +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/value. + else + "`" + value + "`" +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/value. + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/ModuleNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/ModuleNode.pkl new file mode 100755 index 00000000..10a4052d --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/ModuleNode.pkl @@ -0,0 +1,289 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Node representing a Pkl module. + @Unlisted +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Unlisted# + module pkl.experimental.syntax.ModuleNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ + + extends "ClassOrModuleNode.pkl" + + import "AnnotationNode.pkl" + import "DocCommentNode.pkl" + import "Node.pkl" + import "ClassNode.pkl" + import "QualifiedIdentifierNode.pkl" + import "TypeAliasNode.pkl" + + /// The top-level section of a module + /// + /// E.g. `module com.package.MyModule` + declaration: ModuleDeclarationNode? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/declaration. +//documentation +//> The top-level section of a module +//> +//> E.g. `module com.package.MyModule` +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode# + + /// The list of imports for a module. + imports: Listing? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/imports. +//documentation +//> The list of imports for a module. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ImportNode# + + /// The classes as defined in the module. + classes: Listing? +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/classes. +//documentation +//> The classes as defined in the module. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ + + /// The typealiases as defined in the module. + typealiases: Listing? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/typealiases. +//documentation +//> The typealiases as defined in the module. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/ + + class ModuleDeclarationNode extends Node { +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + /// Content for the first line of the module following "#!" + /// Enables modules to be evaluated as executable scripts + /// + /// Example: "/usr/bin/env pkl eval" + shebang: String? +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode#shebang. +// documentation +// > Content for the first line of the module following "#!" +// > Enables modules to be evaluated as executable scripts +// > +// > Example: "/usr/bin/env pkl eval" +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Annotations for the module itself, for instance, `@ModuleInfo` + annotations: Listing? +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode#annotations. +// documentation +// > Annotations for the module itself, for instance, `@ModuleInfo` +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/ + + docComment: DocCommentNode? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode#docComment. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/ + + moduleHeader: ModuleHeaderNode? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode#moduleHeader. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode# + + function render(currentIndent: String) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_57 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + List( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + shebang.ifNonNull((it) -> "#!\(it)"), +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode#shebang. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_59 +// ^^ reference local it_59 + docComment?.render(currentIndent), +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode#docComment. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_57 + annotations?.toList()?.map((a) -> a.render(currentIndent))?.join("\n"), +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode#annotations. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local a_61 +// ^ reference local a_61 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_57 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + moduleHeader?.render(currentIndent) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode#moduleHeader. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_57 + ).filterNonNull().join("\n") +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + + local const renderer = new PcfRenderer {} +// ^^^^^^^^ definition local renderer_66 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer# + + class ModuleHeaderNode extends Node { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + modifiers: Listing<"abstract"|"open">(isDistinct, name != null)? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode#modifiers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode#name. + + name: QualifiedIdentifierNode? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode#name. +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `QualifiedIdentifierNode.pkl`/ + + moduleExtendsOrAmendsClause: ModuleExtendsOrAmendsClauseNode? +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode#moduleExtendsOrAmendsClause. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleExtendsOrAmendsClauseNode# + + function render(header) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode#render(). +// ^^^^^^ definition local header_75 + let (moduleHeader = new Listing { +// ^^^^^^^^^^^^ definition local moduleHeader_76 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + when (modifiers != null) { +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode#modifiers. + modifiers.join(" ") + " " +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode#modifiers. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + } + when (name != null) { +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode#name. + "module " + name.render(header) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode#name. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `QualifiedIdentifierNode.pkl`/render(). +// ^^^^^^ reference local header_75 + } + }.join("")) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + List( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + if (moduleHeader.isEmpty) null else moduleHeader, +// ^^^^^^^^^^^^ reference local moduleHeader_76 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. +// ^^^^^^^^^^^^ reference local moduleHeader_76 + moduleExtendsOrAmendsClause?.render() +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleHeaderNode#moduleExtendsOrAmendsClause. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleExtendsOrAmendsClauseNode#render(). + ).filterNonNull().join("\n\n") +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + + class ModuleExtendsOrAmendsClauseNode extends Node { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleExtendsOrAmendsClauseNode# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + type: "extends"|"amends" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleExtendsOrAmendsClauseNode#type. + extendedModule: String +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleExtendsOrAmendsClauseNode#extendedModule. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + function render() = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleExtendsOrAmendsClauseNode#render(). + """ + \(type) \(renderer.renderValue(extendedModule)) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleExtendsOrAmendsClauseNode#type. +// ^^^^^^^^ reference local renderer_66 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer#renderValue(). +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleExtendsOrAmendsClauseNode#extendedModule. + """ + } + + class ImportNode extends Node { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ImportNode# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + value: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ImportNode#value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + alias: String? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ImportNode#alias. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + keyword: "import"|"import*" = "import" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ImportNode#keyword. + function render() = new Listing { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ImportNode#render(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + keyword +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ImportNode#keyword. + " " + renderer.renderValue(value) +// ^^^^^^^^ reference local renderer_66 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer#renderValue(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ImportNode#value. + when (alias != null) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ImportNode#alias. + " as " + alias +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ImportNode#alias. + } + }.join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + } + + function renderImports() = +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/renderImports(). + (imports?.toList() ?? List()).map((it) -> it.render()).join("\n") +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/imports. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local it_115 +// ^^ reference local it_115 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + function render(currentIndent: String) = List( +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). +// ^^^^^^^^^^^^^ definition local currentIndent_117 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + declaration?.render(currentIndent), +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/declaration. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ModuleDeclarationNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_117 + renderImports(), +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/renderImports(). + super.render(currentIndent), +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_117 + classes?.toList()?.map((c) -> c.render(currentIndent))?.join("\n\n"), +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/classes. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local c_121 +// ^ reference local c_121 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_117 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + typealiases?.toList()?.map((t) -> t.render(currentIndent))?.join("\n\n") +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/typealiases. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local t_122 +// ^ reference local t_122 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_117 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + ) + .filter((line) -> line != null && !line.isEmpty) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filter(). +// ^^^^ definition local line_124 +// ^^^^ reference local line_124 +// ^^^^ reference local line_124 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. + .join("\n\n") + "\n" +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/Node.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/Node.pkl new file mode 100755 index 00000000..92482ed7 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/Node.pkl @@ -0,0 +1,65 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// An abstraction for a Pkl code snippet. + /// + /// Nodes are used for building syntax trees, which can be used to render Pkl source code. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/minPklVersion. + @Unlisted +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Unlisted# + abstract module pkl.experimental.syntax.Node +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + + hidden pcfRenderer: ValueRenderer = new PcfRenderer { useCustomStringDelimiters = true } +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/pcfRenderer. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer# +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer# +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/useCustomStringDelimiters. + + /// The indentation when rendering. + hidden indent: String = " " +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/indent. +// documentation +// > The indentation when rendering. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The max column width to use when rendering. + hidden maxColumnWidth: Int = 100 +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/maxColumnWidth. +// documentation +// > The max column width to use when rendering. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + abstract function render(currentIndent: String): String +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ definition local currentIndent_31 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + function parenthesize(str: String) = "(" + str + ")" +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/parenthesize(). +// ^^^ definition local str_33 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference local str_33 + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/output. + text = render("") +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/text. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/ObjectBodyNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/ObjectBodyNode.pkl new file mode 100755 index 00000000..c88566e7 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/ObjectBodyNode.pkl @@ -0,0 +1,320 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Nodes with curly braces, e.g. { foo = "bar" }. + /// + /// Objects can have properties, entries, and elements. + /// ``` + /// myObj = new { + /// // property + /// foo = "bar" + /// + /// // entry + /// ["baz"] = "biz" + /// + /// // element + /// 5 + /// } + /// ``` + /// + /// To do: For generators, when generators, object spread, member predicate + @Unlisted +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Unlisted# + module pkl.experimental.syntax.ObjectBodyNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + + extends "Node.pkl" + + import "IdentifierNode.pkl" + import "Node.pkl" + import "ObjectBodyNode.pkl" + import "ExpressionNode.pkl" + import "DocCommentNode.pkl" + import "ParameterNode.pkl" + + members: Listing +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/members. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/MemberNode# + + /// Renders all members inline instead of on newlines + renderInline: Boolean = false +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/renderInline. +//documentation +//> Renders all members inline instead of on newlines +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + typealias MemberNode = PropertyMemberNode|ElementMemberNode|EntryMemberNode|ForGeneratorNode|WhenGeneratorNode +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/MemberNode# +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ElementMemberNode# +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/EntryMemberNode# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode# +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/WhenGeneratorNode# + + class PropertyMemberNode extends Node { +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + docComment: DocCommentNode? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#docComment. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/ + + modifiers: Listing<"local">(isDistinct)? +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#modifiers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. + + propertyName: IdentifierNode +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#propertyName. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/ + + body: ObjectBodyNode? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#body. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + + // The right hand side of a property cannot be both an assignment and an object body (e.g. `foo = { ... }` is illegal) + assignment: ExpressionNode(body == null)? +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#assignment. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#body. + + local function renderRhs(currentIndent: String) = if (body != null) body.render(currentIndent) else "= " + assignment.render(currentIndent) +// ^^^^^^^^^ definition local renderRhs_64 +// ^^^^^^^^^^^^^ definition local currentIndent_64 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#body. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#body. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_64 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#assignment. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_64 + + local function renderPropertyLine(currentIndent: String) = new Listing { +// ^^^^^^^^^^^^^^^^^^ definition local renderPropertyLine_66 +// ^^^^^^^^^^^^^ definition local currentIndent_66 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + ...?modifiers +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#modifiers. + propertyName.render(currentIndent) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#propertyName. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_66 + renderRhs(currentIndent) +// ^^^^^^^^^ reference local renderRhs_64 +// ^^^^^^^^^^^^^ reference local currentIndent_66 + }.join(" ") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + + function render(currentIndent: String) = List( +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_72 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + docComment?.render(currentIndent), +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode#docComment. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_72 + renderPropertyLine(currentIndent) +// ^^^^^^^^^^^^^^^^^^ reference local renderPropertyLine_66 +// ^^^^^^^^^^^^^ reference local currentIndent_72 + ) + .filterNonNull() +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). + .join("\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + + class ElementMemberNode extends Node { +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ElementMemberNode# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + value: ExpressionNode +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ElementMemberNode#value. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + function render(currentIndent: String) = value.render(currentIndent) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ElementMemberNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_83 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ElementMemberNode#value. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_83 + } + + class EntryMemberNode extends Node { +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/EntryMemberNode# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + keyValue: ExpressionNode +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/EntryMemberNode#keyValue. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + body: ObjectBodyNode? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/EntryMemberNode#body. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + + // The right hand side of an entry cannot be both an assignment and an object body (e.g. `foo = { ... }` is illegal) + propertyValue: ExpressionNode(body == null)? +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/EntryMemberNode#propertyValue. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/EntryMemberNode#body. + + local function renderRhs(currentIndent: String) = if (body != null) body.render(currentIndent) else "= " + propertyValue.render(currentIndent) +// ^^^^^^^^^ definition local renderRhs_94 +// ^^^^^^^^^^^^^ definition local currentIndent_94 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/EntryMemberNode#body. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/EntryMemberNode#body. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_94 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/EntryMemberNode#propertyValue. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_94 + + function render(currentIndent: String) = "[\(keyValue.render(currentIndent))] \(renderRhs(currentIndent))" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/EntryMemberNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_96 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/EntryMemberNode#keyValue. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_96 +// ^^^^^^^^^ reference local renderRhs_94 +// ^^^^^^^^^^^^^ reference local currentIndent_96 + } + + class ForGeneratorNode extends Node { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + keyParameter: ParameterNode? +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode#keyParameter. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/ + + valueParameter: ParameterNode +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode#valueParameter. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/ + + collection: ExpressionNode +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode#collection. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + body: ObjectBodyNode? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode#body. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + + function doRenderLoopControl(currentIndent: String): String = List( +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode#doRenderLoopControl(). +// ^^^^^^^^^^^^^ definition local currentIndent_108 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + keyParameter?.render(currentIndent)?.ifNonNull((it) -> it + ","), +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode#keyParameter. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_108 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_109 +// ^^ reference local it_109 + valueParameter.render(currentIndent), +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode#valueParameter. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_108 + "in", + collection.render(currentIndent) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode#collection. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_108 + ).filterNonNull().join(" ") +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + function render(currentIndent: String): String = "for (\(doRenderLoopControl(currentIndent))) \(body.render(currentIndent))" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_115 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode#doRenderLoopControl(). +// ^^^^^^^^^^^^^ reference local currentIndent_115 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode#body. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_115 + } + + class WhenGeneratorNode extends Node { +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/WhenGeneratorNode# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + condition: ExpressionNode +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/WhenGeneratorNode#condition. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + body: ObjectBodyNode? +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/WhenGeneratorNode#body. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + + function render(currentIndent: String): String = "when (\(condition.render(currentIndent))) \(body.render(currentIndent))" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/WhenGeneratorNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_123 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/WhenGeneratorNode#condition. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_123 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/WhenGeneratorNode#body. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_123 + } + + local function doRenderInline(currentIndent: String) = "{ " + members.toList().map((m) -> m.render(currentIndent)).join("; ") + " }" +// ^^^^^^^^^^^^^^ definition local doRenderInline_126 +// ^^^^^^^^^^^^^ definition local currentIndent_126 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/members. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local m_126 +// ^ reference local m_126 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/WhenGeneratorNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_126 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + local function doRenderMultiline(currentIndent: String) = +// ^^^^^^^^^^^^^^^^^ definition local doRenderMultiline_128 +// ^^^^^^^^^^^^^ definition local currentIndent_128 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (innerIndent = currentIndent + indent) +// ^^^^^^^^^^^ definition local innerIndent_129 +// ^^^^^^^^^^^^^ reference local currentIndent_128 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/indent. + "{\n" + members.toList().map((m) -> innerIndent + m.render(innerIndent)).join("\n") + "\n\(currentIndent)}" +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/members. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local m_130 +// ^^^^^^^^^^^ reference local innerIndent_129 +// ^ reference local m_130 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/WhenGeneratorNode#render(). +// ^^^^^^^^^^^ reference local innerIndent_129 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). +// ^^^^^^^^^^^^^ reference local currentIndent_128 + + function render(currentIndent: String) = if (renderInline) doRenderInline(currentIndent) else doRenderMultiline(currentIndent) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). +// ^^^^^^^^^^^^^ definition local currentIndent_132 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/renderInline. +// ^^^^^^^^^^^^^^ reference local doRenderInline_126 +// ^^^^^^^^^^^^^ reference local currentIndent_132 +// ^^^^^^^^^^^^^^^^^ reference local doRenderMultiline_128 +// ^^^^^^^^^^^^^ reference local currentIndent_132 + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/ParameterNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/ParameterNode.pkl new file mode 100755 index 00000000..9008c060 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/ParameterNode.pkl @@ -0,0 +1,56 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Node representing a method or function argument declaration. + @Unlisted +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Unlisted# + module pkl.experimental.syntax.ParameterNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/ + + extends "Node.pkl" + + import "TypeAnnotationNode.pkl" + import "IdentifierNode.pkl" + + /// The name of the parameter. May be `_` for an unbound parameter. + name: IdentifierNode +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/name. +//documentation +//> The name of the parameter. May be `_` for an unbound parameter. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/ + + /// The type of the parameter. + typeAnnotation: TypeAnnotationNode? +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/typeAnnotation. +//documentation +//> The type of the parameter. +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAnnotationNode.pkl`/ + + function render(currentIndent: String) = List(name.render(currentIndent), typeAnnotation?.render(currentIndent)) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/render(). +// ^^^^^^^^^^^^^ definition local currentIndent_31 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/name. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_31 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ParameterNode.pkl`/typeAnnotation. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAnnotationNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_31 + .filterNonNull() +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). + .join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/PklProject b/pkl-pantrysnapshot/pkl.experimental.syntax/PklProject new file mode 100755 index 00000000..9e596f4d --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/PklProject @@ -0,0 +1,28 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Experimental Pkl syntax library + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 PklProject/package. + version = "1.1.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 PklProject/version. + apiTests = import*("tests/*.pkl").keys.toListing() +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 PklProject/apiTests. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#keys. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#toListing(). + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/QualifiedIdentifierNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/QualifiedIdentifierNode.pkl new file mode 100755 index 00000000..da5b8978 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/QualifiedIdentifierNode.pkl @@ -0,0 +1,44 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// One or more identifiers, separated by dots, e.g. `foo.bar.baz` + @Unlisted +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Unlisted# + module pkl.experimental.syntax.QualifiedIdentifierNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `QualifiedIdentifierNode.pkl`/ + + extends "Node.pkl" + + import "IdentifierNode.pkl" + + parts: Listing(!isEmpty) +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `QualifiedIdentifierNode.pkl`/parts. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + + function render(currentIndent: String) = parts.toList().map((p) -> p.render(currentIndent)).join(".") +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `QualifiedIdentifierNode.pkl`/render(). +// ^^^^^^^^^^^^^ definition local currentIndent_26 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `QualifiedIdentifierNode.pkl`/parts. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local p_26 +// ^ reference local p_26 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_26 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/TypeAliasNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/TypeAliasNode.pkl new file mode 100755 index 00000000..945540b0 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/TypeAliasNode.pkl @@ -0,0 +1,113 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.TypeAliasNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/ + + extends "Node.pkl" + + import "IdentifierNode.pkl" + import "TypeNode.pkl" + import "DocCommentNode.pkl" + import "AnnotationNode.pkl" + + docComment: DocCommentNode? +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/docComment. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/ + + name: IdentifierNode +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/name. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/ + + type: TypeNode +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/type. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + + annotations: Listing? +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/annotations. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/ + + modifiers: Listing<"external"|"local">(isDistinct)? +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/modifiers. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isDistinct. + + local function renderAlias(currentIndent: String) = +// ^^^^^^^^^^^ definition local renderAlias_35 +// ^^^^^^^^^^^^^ definition local currentIndent_35 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (typeRendered = type.render(currentIndent)) +// ^^^^^^^^^^^^ definition local typeRendered_36 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/type. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_35 + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + renderHeader(currentIndent) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/renderHeader(). +// ^^^^^^^^^^^^^ reference local currentIndent_35 + when (!typeRendered.startsWith("\n")) { // if the type is rendered starting on the next line, do not add a space +// ^^^^^^^^^^^^ reference local typeRendered_36 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + " " + } + typeRendered +// ^^^^^^^^^^^^ reference local typeRendered_36 + }.join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + + function renderHeader(currentIndent: String) = new Listing { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/renderHeader(). +// ^^^^^^^^^^^^^ definition local currentIndent_45 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + ...?modifiers +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/modifiers. + "typealias" + name.render(currentIndent) +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/name. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `IdentifierNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_45 + "=" + }.join(" ") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + + function render(currentIndent: String) = List( +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/render(). +// ^^^^^^^^^^^^^ definition local currentIndent_52 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + docComment?.render(currentIndent), +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/docComment. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `DocCommentNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_52 + annotations?.toList()?.map((an) -> an.render(currentIndent))?.join("\n"), +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAliasNode.pkl`/annotations. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local an_54 +// ^^ reference local an_54 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `AnnotationNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_52 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + currentIndent + renderAlias(currentIndent) +// ^^^^^^^^^^^^^ reference local currentIndent_52 +// ^^^^^^^^^^^ reference local renderAlias_35 +// ^^^^^^^^^^^^^ reference local currentIndent_52 + ).filterNonNull().join("\n") +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#filterNonNull(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/TypeAnnotationNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/TypeAnnotationNode.pkl new file mode 100755 index 00000000..2b3af714 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/TypeAnnotationNode.pkl @@ -0,0 +1,34 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.TypeAnnotationNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAnnotationNode.pkl`/ + + extends "Node.pkl" + + import "TypeNode.pkl" + + type: TypeNode +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAnnotationNode.pkl`/type. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + + function render(currentIndent: String) = ": \(type.render(currentIndent))" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAnnotationNode.pkl`/render(). +// ^^^^^^^^^^^^^ definition local currentIndent_24 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeAnnotationNode.pkl`/type. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_24 + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/TypeNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/TypeNode.pkl new file mode 100755 index 00000000..e82c6257 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/TypeNode.pkl @@ -0,0 +1,249 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + abstract module pkl.experimental.syntax.TypeNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + + extends "Node.pkl" + + import "QualifiedIdentifierNode.pkl" + import "ExpressionNode.pkl" + import "TypeNode.pkl" + import "Node.pkl" + + class NullableTypeNode extends TypeNode { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + typeNode: TypeNode +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode#typeNode. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + function render(currentIndent: String) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_27 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (underlyingRendered = if (typeNode is UnionTypeNode) parenthesize(typeNode.render(currentIndent)) else typeNode.render(currentIndent)) +// ^^^^^^^^^^^^^^^^^^ definition local underlyingRendered_28 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode#typeNode. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/parenthesize(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode#typeNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_27 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/NullableTypeNode#typeNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_27 + underlyingRendered + "?" +// ^^^^^^^^^^^^^^^^^^ reference local underlyingRendered_28 + } + + class BuiltInTypeNode extends TypeNode { +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/BuiltInTypeNode# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + type: "unknown"|"nothing"|"module" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/BuiltInTypeNode#type. + function render(_) = type +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/BuiltInTypeNode#render(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/BuiltInTypeNode#type. + } + + class StringLiteralTypeNode extends TypeNode { +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + value: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode#value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + function render(_) = pcfRenderer.renderValue(value) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode#render(). +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/pcfRenderer. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer#renderValue(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode#value. + } + + class DeclaredTypeNode extends TypeNode { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + name: QualifiedIdentifierNode +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode#name. +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `QualifiedIdentifierNode.pkl`/ + + typeArguments: Listing +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode#typeArguments. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + + local function renderTypeArguments(currentIndent: String) = +// ^^^^^^^^^^^^^^^^^^^ definition local renderTypeArguments_48 +// ^^^^^^^^^^^^^ definition local currentIndent_48 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (typeArguments.isEmpty) "" +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode#typeArguments. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + else "<" + typeArguments.toList().map((t) -> t.render(currentIndent)).join(", ") + ">" +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode#typeArguments. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local t_50 +// ^ reference local t_50 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_48 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + function render(currentIndent: String) = name.render(currentIndent) + renderTypeArguments(currentIndent) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_52 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode#name. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `QualifiedIdentifierNode.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_52 +// ^^^^^^^^^^^^^^^^^^^ reference local renderTypeArguments_48 +// ^^^^^^^^^^^^^ reference local currentIndent_52 + } + + class ConstrainedTypeNode extends TypeNode { +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + /// The underlying type + typeNode: TypeNode +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode#typeNode. +// documentation +// > The underlying type +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + + constraints: Listing +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode#constraints. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ + + local function renderConstraints(currentIndent: String) = +// ^^^^^^^^^^^^^^^^^ definition local renderConstraints_61 +// ^^^^^^^^^^^^^ definition local currentIndent_61 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + "(" + constraints.toList().map((c) -> c.render(currentIndent)).join(", ") + ")" +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode#constraints. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local c_62 +// ^ reference local c_62 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_61 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + function render(currentIndent: String) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_64 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (renderedUnderlyingType = if (typeNode is UnionTypeNode) parenthesize(typeNode.render(currentIndent)) else typeNode.render(currentIndent)) +// ^^^^^^^^^^^^^^^^^^^^^^ definition local renderedUnderlyingType_65 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode#typeNode. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/parenthesize(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode#typeNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode#render(). +// ^^^^^^^^^^^^^ reference local currentIndent_64 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode#typeNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_64 + renderedUnderlyingType + renderConstraints(currentIndent) +// ^^^^^^^^^^^^^^^^^^^^^^ reference local renderedUnderlyingType_65 +// ^^^^^^^^^^^^^^^^^ reference local renderConstraints_61 +// ^^^^^^^^^^^^^ reference local currentIndent_64 + } + + class UnionDefaultType extends Node { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionDefaultType# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/ + typeNode: TypeNode +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionDefaultType#typeNode. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + + function render(currentIndent: String) = "*\(typeNode.render(currentIndent))" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionDefaultType#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_72 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionDefaultType#typeNode. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_72 + } + + class UnionTypeNode extends TypeNode { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + members: Listing(atMostOneUnionDefaultType) +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode#members. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionDefaultType# +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference local atMostOneUnionDefaultType_78 + + const local atMostOneUnionDefaultType = (members: Listing) -> +// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition local atMostOneUnionDefaultType_78 +// ^^^^^^^ definition local members_78 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionDefaultType# + members.fold(0, (acc, member) -> acc + if (member is UnionDefaultType) 1 else 0) <= 1 +// ^^^^^^^ reference local members_78 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#fold(). +// ^^^ definition local acc_79 +// ^^^^^^ definition local member_79 +// ^^^ reference local acc_79 +// ^^^^^^ reference local member_79 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionDefaultType# + + function render(currentIndent: String) = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode#render(). +// ^^^^^^^^^^^^^ definition local currentIndent_81 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (childrenRendered = members.toList().map((t) -> t.render(currentIndent))) +// ^^^^^^^^^^^^^^^^ definition local childrenRendered_82 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode#members. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local t_82 +// ^ reference local t_82 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/render(). +// ^^^^^^^^^^^^^ reference local currentIndent_81 + // Multiline if length exceeds `maxColumnWidth` chars. + // If multiline, indent one level deeper. + if (childrenRendered.fold(0, (acc, elem) -> acc + elem.length) > maxColumnWidth) +// ^^^^^^^^^^^^^^^^ reference local childrenRendered_82 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^ definition local acc_85 +// ^^^^ definition local elem_85 +// ^^^ reference local acc_85 +// ^^^^ reference local elem_85 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/maxColumnWidth. + "\n\(currentIndent + indent)" + childrenRendered.join("\n\(currentIndent + indent)|") +// ^^^^^^^^^^^^^ reference local currentIndent_81 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/indent. +// ^^^^^^^^^^^^^^^^ reference local childrenRendered_82 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). +// ^^^^^^^^^^^^^ reference local currentIndent_81 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `Node.pkl`/indent. + else + childrenRendered.join("|") +// ^^^^^^^^^^^^^^^^ reference local childrenRendered_82 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + + // TODO fill me in + class FunctionTypeNode extends TypeNode { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/FunctionTypeNode# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ + + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/operators.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/operators.pkl new file mode 100755 index 00000000..78345240 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/operators.pkl @@ -0,0 +1,240 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.operators +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ + + typealias Multiply = "*" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Multiply# + + typealias Divide = "/" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Divide# + + typealias Plus = "+" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Plus# + + typealias BinaryMinus = "-" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BinaryMinus# + + typealias Modulo = "%" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Modulo# + + typealias GreaterThan = ">" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GreaterThan# + + typealias LessThan = "<" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LessThan# + + typealias GreaterThanOrEquals = ">=" +// ^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GreaterThanOrEquals# + + typealias LessThanOrEquals = "<=" +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LessThanOrEquals# + + typealias IntegerDivide = "~/" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/IntegerDivide# + + typealias Equals = "==" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Equals# + + typealias NotEquals = "!=" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NotEquals# + + typealias NullishCoalesce = "??" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NullishCoalesce# + + typealias Pipe = "|>" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Pipe# + + typealias BitwiseAnd = "&" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BitwiseAnd# + + typealias BitwiseOr = "|" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BitwiseOr# + + typealias Exponent = "**" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Exponent# + + typealias Is = "is" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Is# + + typealias As = "as" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/As# + + typealias And = "&&" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/And# + + typealias Or = "||" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Or# + + typealias Not = "!" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Not# + + typealias UnaryMinus = "-" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/UnaryMinus# + + typealias NonNullAssertion = "!!" +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NonNullAssertion# + + typealias BinaryOperator = +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BinaryOperator# + Multiply +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Multiply# + |Divide +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Divide# + |Plus +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Plus# + |BinaryMinus +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BinaryMinus# + |Modulo +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Modulo# + |GreaterThan +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GreaterThan# + |GreaterThanOrEquals +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GreaterThanOrEquals# + |LessThan +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LessThan# + |LessThanOrEquals +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LessThanOrEquals# + |IntegerDivide +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/IntegerDivide# + |Equals +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Equals# + |NotEquals +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NotEquals# + |NullishCoalesce +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NullishCoalesce# + |Pipe +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Pipe# + |BitwiseAnd +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BitwiseAnd# + |BitwiseOr +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BitwiseOr# + |Exponent +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Exponent# + |Is +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Is# + |As +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/As# + |And +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/And# + |Or +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Or# + + typealias PrefixOperator = Not|UnaryMinus +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/PrefixOperator# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Not# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/UnaryMinus# + + typealias PostfixOperator = NonNullAssertion +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/PostfixOperator# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NonNullAssertion# + + MULTIPLY: Multiply +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/MULTIPLY. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Multiply# + + DIVIDE: Divide +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/DIVIDE. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Divide# + + PLUS: Plus +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/PLUS. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Plus# + + BINARY_MINUS: BinaryMinus +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BINARY_MINUS. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BinaryMinus# + + MODULO: Modulo +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/MODULO. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Modulo# + + GREATER_THAN: GreaterThan +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GreaterThan# + + LESS_THAN: LessThan +//^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LessThan# + + GREATER_THAN_OR_EQUALS: GreaterThanOrEquals +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GREATER_THAN_OR_EQUALS. +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/GreaterThanOrEquals# + + LESS_THAN_OR_EQUALS: LessThanOrEquals +//^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LESS_THAN_OR_EQUALS. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/LessThanOrEquals# + + INTEGER_DIVIDE: IntegerDivide +//^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/INTEGER_DIVIDE. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/IntegerDivide# + + EQUALS: Equals +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/EQUALS. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Equals# + + NOT_EQUALS: NotEquals +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NOT_EQUALS. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NotEquals# + + NULLISH_COALESCE: NullishCoalesce +//^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NULLISH_COALESCE. +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NullishCoalesce# + + PIPE: Pipe +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/PIPE. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Pipe# + + BITWISE_AND: BitwiseAnd +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BITWISE_AND. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BitwiseAnd# + + BITWISE_OR: BitwiseOr +//^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BITWISE_OR. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/BitwiseOr# + + EXPONENT: Exponent +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/EXPONENT. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Exponent# + + IS: Is +//^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/IS. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Is# + + AS: As +//^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/AS. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/As# + + AND: And +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/AND. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/And# + + OR: Or +//^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/OR. +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Or# + + NOT: Not +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NOT. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/Not# + + NON_NULL_ASSERTION: NonNullAssertion +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NON_NULL_ASSERTION. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/NonNullAssertion# + + UNARY_MINUS: UnaryMinus +//^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/UNARY_MINUS. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/UnaryMinus# + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ClassNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ClassNode.pkl new file mode 100755 index 00000000..8f0d62be --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ClassNode.pkl @@ -0,0 +1,61 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.tests.ClassNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassNode.pkl`/ + + amends "pkl:test" + + import "../ClassNode.pkl" + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassNode.pkl`/facts. + ["extending"] { + new ClassNode { +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/ + classHeader { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassNode.pkl`/classHeader. + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassNode.pkl`/name. + value = "MyClass" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassNode.pkl`/value. + } + extendsClause { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassNode.pkl`/extendsClause. + type { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassNode.pkl`/type. + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassNode.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassNode.pkl`/parts. + new { + value = "Base" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassNode.pkl`/value. + } + } + } + } + } + } + + }.render("") == """ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassNode.pkl`/render(). + class MyClass extends Base { + + } + """ + } + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ClassOrModuleNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ClassOrModuleNode.pkl new file mode 100755 index 00000000..8b29895f --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ClassOrModuleNode.pkl @@ -0,0 +1,115 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.tests.ClassOrModuleNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/ + + amends "pkl:test" + + import "../ClassOrModuleNode.pkl" + import "../TypeNode.pkl" + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/facts. + ["property definitions"] { + new ClassOrModuleNode.PropertyDefinitionNode { +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/name. + value = "myProperty" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/value. + } + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/typeAnnotation. + type = new TypeNode.StringLiteralTypeNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/type. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# + value = "my string" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/value. + } + } + }.render("") == """ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#render(). + myProperty: "my string" + """ + } + ["property definitions - annotations"] { + local prop = new ClassOrModuleNode.PropertyDefinitionNode { +// ^^^^ definition local prop_39 +// ^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/name. + value = "myProperty" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/value. + } + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/typeAnnotation. + type = new TypeNode.DeclaredTypeNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/type. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/parts. + new { value = "MyType" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/value. + } + } + } + } + docComment { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/docComment. + value = """ +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/value. + This has been deprecated + + because of stuff. + """ + } + annotations { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/annotations. + new { + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/identifier. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/parts. + new { value = "Deprecated" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ClassOrModuleNode.pkl`/value. + } + } + } + } + } + prop.render("") == """ +// ^^^^ reference local prop_39 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#render(). + /// This has been deprecated + /// + /// because of stuff. + @Deprecated + myProperty: MyType + """ + prop.render(" ") == """ +// ^^^^ reference local prop_39 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ClassOrModuleNode.pkl`/PropertyDefinitionNode#render(). + /// This has been deprecated + /// + /// because of stuff. + @Deprecated + myProperty: MyType + """ + } + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ExpressionNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ExpressionNode.pkl new file mode 100755 index 00000000..30b42aa4 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ExpressionNode.pkl @@ -0,0 +1,423 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.tests.ExpressionNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/ + + amends "pkl:test" + + import "../ExpressionNode.pkl" + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/examples. + ["binary operators - basic"] { + new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = "foo" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + operator = "+" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + rhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = "bar" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#render(). + } + ["binary operators - precedence: no parentheses when child precedence is higher"] { + new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + operator = "+" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + lhs = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = 5 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + rhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = 5 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + operator = "*" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + } + rhs = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = 5 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + rhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = 5 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + operator = "*" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#render(). + } + ["binary operators - precedence: parenthese added when child precedence is lower"] { + new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + operator = "*" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + lhs = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = 5 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + rhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = 5 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + operator = "+" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + } + rhs = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = 5 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + rhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = 5 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + operator = "+" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode#render(). + } + ["unary operators"] { + new ExpressionNode.PrefixOperatorExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode# + operator = "!" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + expression = new ExpressionNode.LiteralValueExpressionNode { value = false } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/expression. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode#render(). + } + ["unary operators - parenthesizes binary expressions"] { + new ExpressionNode.PrefixOperatorExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode# + operator = "-" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + expression = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/expression. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + operator = "+" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + lhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = 5 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + rhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = 10 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/PrefixOperatorExpressionNode#render(). + } + ["member access - single identifier"] { + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. + value = "foo" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#render(). + } + ["member access - method call"] { + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. + value = "foo" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + arguments { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/arguments. + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. + value = "bar" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + } + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. + value = "biz" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + } + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode#render(). + } + ["if/else"] { + new ExpressionNode.IfElseExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode# + condition = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/condition. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = new ExpressionNode.MemberAccessExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. + value = "foo" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + } + operator = "==" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + rhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = "foo" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + } + ifBranch = new ExpressionNode.LiteralValueExpressionNode { value = "foo" } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/ifBranch. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + elseBranch = new ExpressionNode.LiteralValueExpressionNode { value = "bar" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/elseBranch. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#render(). + + new ExpressionNode.IfElseExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode# + condition = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/condition. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = new ExpressionNode.MemberAccessExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. + value = "foo" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + } + operator = "==" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + rhs = new ExpressionNode.LiteralValueExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = "foo" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + } + ifBranch = new ExpressionNode.LiteralValueExpressionNode { value = "foo" } +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/ifBranch. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + elseBranch = new ExpressionNode.LiteralValueExpressionNode { value = "bar" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/elseBranch. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + }.render(" ") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode#render(). + } + ["super access"] { + new ExpressionNode.SuperAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperAccessExpressionNode# + rhs { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. + identifier { value = "someProperty" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperAccessExpressionNode#render(). + new ExpressionNode.SuperAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperAccessExpressionNode# + rhs { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. + identifier { value = "someProperty" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + arguments { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/arguments. + new ExpressionNode.LiteralValueExpressionNode { value = true } +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperAccessExpressionNode#render(). + } + ["super subscript"] { + new ExpressionNode.SuperSubscriptExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperSubscriptExpressionNode# + subscript = new ExpressionNode.LiteralValueExpressionNode { value = "test" } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/subscript. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SuperSubscriptExpressionNode#render(). + } + ["subscript"] { + new ExpressionNode.SubscriptExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode# + lhs = new ExpressionNode.MemberAccessExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { value = "test" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + subscript = new ExpressionNode.LiteralValueExpressionNode { value = "key" } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/subscript. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode#render(). + new ExpressionNode.SubscriptExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode# + lhs = new ExpressionNode.IfElseExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/IfElseExpressionNode# + condition = new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/condition. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { value = "test" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + ifBranch = new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/ifBranch. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { value = "testTrue" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + elseBranch = new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/elseBranch. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { value = "testFalse" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + } + subscript = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/subscript. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + operator = "+" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/operator. + lhs = new ExpressionNode.LiteralValueExpressionNode { value = "test" } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + rhs = new ExpressionNode.LiteralValueExpressionNode { value = "Key" } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/SubscriptExpressionNode#render(). + } + ["read"] { + new ExpressionNode.ReadExpressionNode { +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode# + value = new ExpressionNode.LiteralValueExpressionNode { value = "env:HOME" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode#render(). + new ExpressionNode.ReadExpressionNode { +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode# + keyword = "read*" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/keyword. + value = new ExpressionNode.LiteralValueExpressionNode { value = "env:HOME" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode#render(). + new ExpressionNode.ReadExpressionNode { +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode# + keyword = "read?" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/keyword. + value = new ExpressionNode.LiteralValueExpressionNode { value = "env:HOME" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ReadExpressionNode#render(). + } + ["trace"] { + new ExpressionNode.TraceExpressionNode { +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/TraceExpressionNode# + value = new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { value = "test" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ExpressionNode.pkl`/value. + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/TraceExpressionNode#render(). + } + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ModuleNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ModuleNode.pkl new file mode 100755 index 00000000..7ac815a7 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ModuleNode.pkl @@ -0,0 +1,383 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.tests.ModuleNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/ + + amends "pkl:test" + + import "../ModuleNode.pkl" + import "../TypeNode.pkl" + import "../ExpressionNode.pkl" + import "../ObjectBodyNode.pkl" + import "../operators.pkl" + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/facts. + ["new line at the end"] { + new ModuleNode { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ + declaration { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/declaration. + moduleHeader { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/moduleHeader. + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/parts. + new { value = "modulename" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + } + } + } + } + }.output.text == """ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + module modulename + + """ + } + } + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/examples. + ["full declaration"] { + new ModuleNode { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ + declaration { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/declaration. + shebang = "/usr/bin/env pkl eval" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/shebang. + annotations { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/annotations. + new { + identifier { parts { new { value = "test" } } } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/parts. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + body { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/body. + renderInline = true +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/renderInline. + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/members. + new ObjectBodyNode.PropertyMemberNode { +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode# + propertyName { value = "annotation" } +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/propertyName. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + assignment = new ExpressionNode.LiteralValueExpressionNode { value = true } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/assignment. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + } + } + } + } + } + docComment { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/docComment. + value = """ +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + This is a module doc comment! + """ + } + moduleHeader { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/moduleHeader. + modifiers { "open" } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/modifiers. + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/parts. + new { value = "pkl" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new { value = "experimental" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new { value = "syntax" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new { value = "tests" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new { value = "ModuleNode" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + } + } + moduleExtendsOrAmendsClause { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/moduleExtendsOrAmendsClause. + type = "amends" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/type. + extendedModule = "pkl:test" +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/extendedModule. + } + } + } + }.output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + ["short methods are rendered inline"] { + new ModuleNode { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ + methods { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/methods. + new { + docComment { value = "Adds five to its argument." } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/docComment. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + modifiers { "const"; "local" } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/modifiers. + name { value = "addFive" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/parameters. + new { + name { value = "input" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/typeAnnotation. + type = new TypeNode.DeclaredTypeNode { name { parts { new { value = "Int" } } } } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/type. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/parts. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + } + } + } + body = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/body. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = new ExpressionNode.MemberAccessExpressionNode { identifier { value = "input" } } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + operator = operators.PLUS +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/operator. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/PLUS. + rhs = new ExpressionNode.LiteralValueExpressionNode { value = 5 } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + } + } + } + }.output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + ["methods with long values are rendered indented"] { + new ModuleNode { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ + methods { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/methods. + new { + docComment { value = "Adds five to its argument." } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/docComment. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + modifiers { "const"; "local" } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/modifiers. + name { value = "myReallyLongMethodForAddingFiveToAnInteger" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/parameters. + new { + name { value = "inputIntegerValue" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/typeAnnotation. + type = new TypeNode.DeclaredTypeNode { name { parts { new { value = "Int" } } } } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/type. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/parts. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + } + } + } + body = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/body. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = new ExpressionNode.MemberAccessExpressionNode { identifier { value = "inputIntegerValue" } } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + operator = operators.PLUS +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/operator. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/PLUS. + rhs = new ExpressionNode.LiteralValueExpressionNode { value = 5 } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + } + } + } + }.output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + ["methods with long values but short first lines are rendered inline"] { + new ModuleNode { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ + methods { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/methods. + new { + docComment { value = "Adds five to its argument and returns a dynamic object containing the result." } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/docComment. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + modifiers { "const"; "local" } +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/modifiers. + name { value = "myLongMethodForReturningADynamicObject" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + parameters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/parameters. + new { + name { value = "inputIntegerValue" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/typeAnnotation. + type = new TypeNode.DeclaredTypeNode { name { parts { new { value = "Int" } } } } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/type. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/parts. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + } + } + } + body = new ExpressionNode.ObjectExpressionNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/body. +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/ObjectExpressionNode# + type = new TypeNode.DeclaredTypeNode { name { parts { new { value = "Dynamic" } } } } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/type. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/parts. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + body { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/body. + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/members. + new ObjectBodyNode.PropertyMemberNode { +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode# + propertyName { value = "value" } +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/propertyName. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + assignment = new ExpressionNode.BinaryOperatorExpressionNode { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/assignment. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/BinaryOperatorExpressionNode# + lhs = new ExpressionNode.MemberAccessExpressionNode { identifier { value = "inputIntegerValue" } } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + operator = operators.PLUS +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/operator. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/ +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `operators.pkl`/PLUS. + rhs = new ExpressionNode.LiteralValueExpressionNode { value = 5 } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/rhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + } + } + } + } + } + } + } + }.output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + ["typealiases"] { + new ModuleNode { +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ModuleNode.pkl`/ + typealiases { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/typealiases. + new { + name { value = "Short" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + type = new TypeNode.UnionTypeNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/type. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode# + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/members. + new TypeNode.StringLiteralTypeNode { value = "A" } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new TypeNode.StringLiteralTypeNode { value = "B" } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + } + } + } + new { + name { value = "Long" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + type = new TypeNode.UnionTypeNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/type. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode# + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/members. + new TypeNode.StringLiteralTypeNode { value = "Apple" } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new TypeNode.StringLiteralTypeNode { value = "Blackberry" } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new TypeNode.StringLiteralTypeNode { value = "Cherry" } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new TypeNode.StringLiteralTypeNode { value = "Durian" } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new TypeNode.StringLiteralTypeNode { value = "Elderberry" } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new TypeNode.StringLiteralTypeNode { value = "Fig" } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new TypeNode.StringLiteralTypeNode { value = "Guava" } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new TypeNode.StringLiteralTypeNode { value = "Huckleberry" } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + new TypeNode.StringLiteralTypeNode { value = "I_can't_think_of_a_fruit_that_starts_with_I" } +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ModuleNode.pkl`/value. + } + } + } + } + }.output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ObjectBodyNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ObjectBodyNode.pkl new file mode 100755 index 00000000..a16033fc --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/ObjectBodyNode.pkl @@ -0,0 +1,278 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.tests.ObjectBodyNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/ + + amends "pkl:test" + + import "../ObjectBodyNode.pkl" + import "../ExpressionNode.pkl" + import "../TypeNode.pkl" + + local personDotName = new ExpressionNode.QualifiedMemberAccessExpressionNode { +// ^^^^^^^^^^^^^ definition local personDotName_24 +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/QualifiedMemberAccessExpressionNode# + lhs = new ExpressionNode.MemberAccessExpressionNode { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/lhs. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { value = "person" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + rhs { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/rhs. + identifier { value = "name" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + } + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/examples. + ["for generator"] { + // only value w/o type + new ObjectBodyNode { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/members. + new ObjectBodyNode.ForGeneratorNode { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode# + valueParameter { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/valueParameter. + name { value = "person" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + collection = new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/collection. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { value = "people" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + body { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/body. + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/members. + new ObjectBodyNode.ElementMemberNode { +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ElementMemberNode# + value = personDotName +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. +// ^^^^^^^^^^^^^ reference local personDotName_24 + } + } + } + } + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). + // only value w/ type + new ObjectBodyNode { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/members. + new ObjectBodyNode.ForGeneratorNode { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode# + valueParameter { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/valueParameter. + name { value = "person" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/typeAnnotation. + type = new TypeNode.DeclaredTypeNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/type. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/name. + parts { new { value = "Person" } } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/parts. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + } + } + } + collection = new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/collection. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { value = "people" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + body { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/body. + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/members. + new ObjectBodyNode.ElementMemberNode { +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ElementMemberNode# + value = personDotName +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. +// ^^^^^^^^^^^^^ reference local personDotName_24 + } + } + } + } + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). + // key and value w/o types + new ObjectBodyNode { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/members. + new ObjectBodyNode.ForGeneratorNode { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode# + keyParameter { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/keyParameter. + name { value = "personIndex" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + valueParameter { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/valueParameter. + name { value = "person" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + collection = new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/collection. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { value = "people" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + body { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/body. + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/members. + new ObjectBodyNode.ElementMemberNode { +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ElementMemberNode# + value = personDotName +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. +// ^^^^^^^^^^^^^ reference local personDotName_24 + } + } + } + } + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). + // key and value w/ types + new ObjectBodyNode { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/members. + new ObjectBodyNode.ForGeneratorNode { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ForGeneratorNode# + keyParameter { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/keyParameter. + name { value = "personIndex" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/typeAnnotation. + type = new TypeNode.DeclaredTypeNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/type. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/name. + parts { new { value = "Int" } } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/parts. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + } + } + } + valueParameter { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/valueParameter. + name { value = "person" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/name. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + typeAnnotation { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/typeAnnotation. + type = new TypeNode.DeclaredTypeNode { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/type. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/name. + parts { new { value = "Person" } } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/parts. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + } + } + } + collection = new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/collection. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { value = "people" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + body { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/body. + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/members. + new ObjectBodyNode.ElementMemberNode { +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ElementMemberNode# + value = personDotName +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. +// ^^^^^^^^^^^^^ reference local personDotName_24 + } + } + } + } + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). + } + ["when generator"] { + new ObjectBodyNode { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/ + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/members. + new ObjectBodyNode.WhenGeneratorNode { +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/WhenGeneratorNode# + condition = new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/condition. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { value = "test" } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/identifier. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + body { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/body. + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/members. + new ObjectBodyNode.PropertyMemberNode { +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/PropertyMemberNode# + propertyName { value = "conditionalProperty" } +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/propertyName. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + assignment = new ExpressionNode.LiteralValueExpressionNode { value = true } +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/assignment. +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/ObjectBodyNode.pkl`/value. + } + } + } + } + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ObjectBodyNode.pkl`/render(). + } + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.syntax/tests/TypeNode.pkl b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/TypeNode.pkl new file mode 100755 index 00000000..13f11af3 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.syntax/tests/TypeNode.pkl @@ -0,0 +1,216 @@ + //===----------------------------------------------------------------------===// + // 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.syntax.tests.TypeNode +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/ + + amends "pkl:test" + + import "../TypeNode.pkl" + import "../ExpressionNode.pkl" + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/facts. + ["declared type"] { + new TypeNode.DeclaredTypeNode { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/parts. + new { value = "String" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + }.render("") == "String" +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode#render(). + new TypeNode.DeclaredTypeNode { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/parts. + new { value = "myModule" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + new { value = "Bar" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + }.render("") == "myModule.Bar" +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode#render(). + } + ["declared type - type arguments"] { + new TypeNode.DeclaredTypeNode { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/parts. + new { value = "Listing" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + typeArguments { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/typeArguments. + new TypeNode.DeclaredTypeNode { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/parts. + new { value = "Bar" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + } + new TypeNode.DeclaredTypeNode { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/parts. + new { value = "Baz" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + } + } + }.render("") == "Listing" +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode#render(). + } + ["constrained"] { + new TypeNode.ConstrainedTypeNode { +// ^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode# + typeNode = new TypeNode.DeclaredTypeNode { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/typeNode. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/DeclaredTypeNode# + name { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/name. + parts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/parts. + new { value = "Bar" } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + } + constraints { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/constraints. + new ExpressionNode.MemberAccessExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/MemberAccessExpressionNode# + identifier { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/identifier. + value = "isLessThan" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + arguments { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/arguments. + new ExpressionNode.LiteralValueExpressionNode { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `ExpressionNode.pkl`/LiteralValueExpressionNode# + value = 5 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + } + } + }.render("") == "Bar(isLessThan(5))" +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/ConstrainedTypeNode#render(). + } + ["string literal"] { + new TypeNode.StringLiteralTypeNode { +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# + value = "my string type" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + }.render("") == """ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode#render(). + "my string type" + """ + } + ["union"] { + new TypeNode.UnionTypeNode { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode# + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/members. + new TypeNode.StringLiteralTypeNode { +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# + value = "one" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + new TypeNode.StringLiteralTypeNode { +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# + value = "two" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + }.render("") == """ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode#render(). + "one"|"two" + """ + + new TypeNode.UnionTypeNode { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode# + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/members. + new TypeNode.UnionDefaultType { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionDefaultType# + typeNode = new TypeNode.StringLiteralTypeNode { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/typeNode. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# + value = "one" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + new TypeNode.StringLiteralTypeNode { +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# + value = "two" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + }.render("") == """ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode#render(). + *"one"|"two" + """ + + module.catch(() -> +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). + new TypeNode.UnionTypeNode { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode# + members { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/members. + new TypeNode.UnionDefaultType { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionDefaultType# + typeNode = new TypeNode.StringLiteralTypeNode { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/typeNode. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# + value = "one" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + new TypeNode.UnionDefaultType { +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionDefaultType# + typeNode = new TypeNode.StringLiteralTypeNode { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/typeNode. +// ^^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/StringLiteralTypeNode# + value = "two" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `tests/TypeNode.pkl`/value. + } + } + } + }.render("") +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax 1.1.0 `TypeNode.pkl`/UnionTypeNode#render(). + ).startsWith("Type constraint `atMostOneUnionDefaultType` violated.") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + } + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.uri/PklProject b/pkl-pantrysnapshot/pkl.experimental.uri/PklProject new file mode 100755 index 00000000..08e2f483 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.uri/PklProject @@ -0,0 +1,23 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 PklProject/package. + version = "1.0.3" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.uri/URI.pkl b/pkl-pantrysnapshot/pkl.experimental.uri/URI.pkl new file mode 100755 index 00000000..07a0eaf1 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.uri/URI.pkl @@ -0,0 +1,1043 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A Uniform Resource Identifier as defined by + /// [RFC-3986](https://datatracker.ietf.org/doc/html/rfc3986). + /// + /// [URI]s may be constructed literally, or parsed from a string via [parse]. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/minPklVersion. + module pkl.experimental.uri.URI +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + + import "URI.pkl" + + /// The scheme component. + scheme: String? +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The user information portion of the authority component. + userInfo: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/userInfo. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The host portion of the authority component. + host: String? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/host. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The port portion of the authority component. + port: UInt16? +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/port. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt16# + + /// The path component, URI-encoded. + /// + /// Access the decoded form of the path via [pathSegments]. + path: UriString = "" +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/UriString# + + /// The authority component of the URI. + function authority(): String? = +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/authority(). +// documentation +// > The authority component of the URI. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (hasAuthority()) +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/hasAuthority(). + List( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + "//", + if (userInfo != null) "\(encode(userInfo))@" else "", +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/userInfo. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/userInfo. + encode(host!!), +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/host. + if (port != null) ":\(port)" else "" +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/port. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/port. + ) + .join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + else null + + /// The URI path split into its segments. + /// + /// Each segment is decoded. + fixed pathSegments: List = +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// documentation +// > The URI path split into its segments. +// > +// > Each segment is decoded. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (parts = path.split("/").map((it) -> percentDecode(it))) +// ^^^^^ definition local parts_58 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local it_58 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). +// ^^ reference local it_58 + if (hasAbsolutePath) parts.drop(1) +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/hasAbsolutePath. +// ^^^^^ reference local parts_58 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). + else parts +// ^^^^^ reference local parts_58 + + /// The query component, URI-encoded. + query: UriString? +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/UriString# + + /// The fragment component. + fragment: String? +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/fragment. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The base path portion of this URI. + /// + /// This equivalent to the current URI without its query and fragment components. + hidden basePath: URI = (module) { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/basePath. +// documentation +// > The base path portion of this URI. +// > +// > This equivalent to the current URI without its query and fragment components. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + query = null +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. + fragment = null +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/fragment. + } + + /// Tells if this URI is an [absolute URI](https://datatracker.ietf.org/doc/html/rfc3986#section-4.3). + hidden isAbsolute: Boolean = scheme != null +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/isAbsolute. +// documentation +// > Tells if this URI is an [absolute URI](https://datatracker.ietf.org/doc/html/rfc3986#section-4.3). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. + + /// Tells if the [path] is absolute. + hidden hasAbsolutePath: Boolean = path?.startsWith("/") ?? false +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/hasAbsolutePath. +// documentation +// > Tells if the [`path`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.uri/URI.pkl#L40,C1) is absolute. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + + /// Tells if this URI has an [authority](https://datatracker.ietf.org/doc/html/rfc3986#section-3.2). + function hasAuthority(): Boolean = (userInfo ?? host ?? port) != null +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/hasAuthority(). +// documentation +// > Tells if this URI has an [authority](https://datatracker.ietf.org/doc/html/rfc3986#section-3.2). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/userInfo. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/host. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/port. + + // + local function _removeDotSegments(input: List, result: List): List = +// ^^^^^^^^^^^^^^^^^^ definition local _removeDotSegments_86 +// ^^^^^ definition local input_86 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ definition local result_86 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (input.isEmpty) result +// ^^^^^ reference local input_86 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^^^^ reference local result_86 + else + let (currentSegment = input.first) +// ^^^^^^^^^^^^^^ definition local currentSegment_89 +// ^^^^^ reference local input_86 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. + if (currentSegment == ".") +// ^^^^^^^^^^^^^^ reference local currentSegment_89 + _removeDotSegments(input.drop(1), result) +// ^^^^^^^^^^^^^^^^^^ reference local _removeDotSegments_86 +// ^^^^^ reference local input_86 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^^^^ reference local result_86 + else if (currentSegment == "..") +// ^^^^^^^^^^^^^^ reference local currentSegment_89 + _removeDotSegments(input.drop(1), result.dropLast(1)) +// ^^^^^^^^^^^^^^^^^^ reference local _removeDotSegments_86 +// ^^^^^ reference local input_86 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^^^^ reference local result_86 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#dropLast(). + else + _removeDotSegments(input.drop(1), result.add(currentSegment)) +// ^^^^^^^^^^^^^^^^^^ reference local _removeDotSegments_86 +// ^^^^^ reference local input_86 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^^^^ reference local result_86 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^^^^^^^^^^ reference local currentSegment_89 + + local function removeDotSegments(input: String): String = +// ^^^^^^^^^^^^^^^^^ definition local removeDotSegments_97 +// ^^^^^ definition local input_97 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + _removeDotSegments(input.split("/"), List()).join("/") +// ^^^^^^^^^^^^^^^^^^ reference local _removeDotSegments_86 +// ^^^^^ reference local input_97 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + if (input.endsWith("/")) "/" else "" +// ^^^^^ reference local input_97 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#endsWith(). + + // + local function mergePaths(base: URI, other: URI): String = +// ^^^^^^^^^^ definition local mergePaths_102 +// ^^^^ definition local base_102 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ definition local other_102 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (other.hasAbsolutePath) +// ^^^^^ reference local other_102 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/hasAbsolutePath. + other.path +// ^^^^^ reference local other_102 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. + else if (base.hasAuthority() && base.path == "") +// ^^^^ reference local base_102 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/hasAuthority(). +// ^^^^ reference local base_102 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. + "/" + other.path +// ^^^^^ reference local other_102 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. + else + let (basePath = if (base.path.contains("/")) base.path.substring(0, base.path.lastIndexOf("/") + 1) else "/") +// ^^^^^^^^ definition local basePath_108 +// ^^^^ reference local base_102 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). +// ^^^^ reference local base_102 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^^^ reference local base_102 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#lastIndexOf(). + removeDotSegments(basePath + other.path) +// ^^^^^^^^^^^^^^^^^ reference local removeDotSegments_97 +// ^^^^^^^^ reference local basePath_108 +// ^^^^^ reference local other_102 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. + + /// Resolves [other] as a URI reference to this URI. + /// + /// Follows the rules described in + /// [RFC-3986 Section 5.2](https://www.rfc-editor.org/rfc/rfc3986#section-5.2). + function resolveUri(other: URI): URI = +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolveUri(). +// documentation +// > Resolves [`other`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.uri/URI.pkl#L115,C21) as a URI reference to this URI. +// > +// > Follows the rules described in +// > [RFC-3986 Section 5.2](https://www.rfc-editor.org/rfc/rfc3986#section-5.2). +// ^^^^^ definition local other_115 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + let (self = this) +// ^^^^ definition local self_116 + new { + when (other.scheme != null) { +// ^^^^^ reference local other_115 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. + scheme = other.scheme +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. +// ^^^^^ reference local other_115 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. + userInfo = other.userInfo +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/userInfo. +// ^^^^^ reference local other_115 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/userInfo. + host = other.host +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/host. +// ^^^^^ reference local other_115 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/host. + port = other.port +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/port. +// ^^^^^ reference local other_115 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/port. + path = other.path +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^ reference local other_115 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. + query = other.query +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. +// ^^^^^ reference local other_115 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. + } else { + scheme = self.scheme +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. +// ^^^^ reference local self_116 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. + when (other.hasAuthority()) { +// ^^^^^ reference local other_115 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/hasAuthority(). + userInfo = other.userInfo +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/userInfo. +// ^^^^^ reference local other_115 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/userInfo. + host = other.host +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/host. +// ^^^^^ reference local other_115 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/host. + port = other.port +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/port. +// ^^^^^ reference local other_115 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/port. + path = removeDotSegments(other.path) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^^^^^^^^^^^^^ reference local removeDotSegments_97 +// ^^^^^ reference local other_115 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. + } else { + userInfo = self.userInfo +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/userInfo. +// ^^^^ reference local self_116 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/userInfo. + host = self.host +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/host. +// ^^^^ reference local self_116 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/host. + port = self.port +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/port. +// ^^^^ reference local self_116 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/port. + when (other.path == "") { +// ^^^^^ reference local other_115 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. + path = self.path +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^ reference local self_116 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. + query = other.query ?? self.query +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. +// ^^^^^ reference local other_115 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. +// ^^^^ reference local self_116 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. + } else { + path = mergePaths(self, other) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^^^^^^ reference local mergePaths_102 +// ^^^^ reference local self_116 +// ^^^^^ reference local other_115 + query = other.query +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. +// ^^^^^ reference local other_115 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. + } + } + } + fragment = other.fragment +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/fragment. +// ^^^^^ reference local other_115 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/fragment. + } + + /// Resolves [other] as a URI string to this URI. + function resolve(other: String): URI? = +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// documentation +// > Resolves [`other`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.uri/URI.pkl#L149,C18) as a URI string to this URI. +// ^^^^^ definition local other_149 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + let (parsed = parse(other)) +// ^^^^^^ definition local parsed_150 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^ reference local other_149 + if (parsed == null) null +// ^^^^^^ reference local parsed_150 + else resolveUri(parsed) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolveUri(). +// ^^^^^^ reference local parsed_150 + + function toString(): String = new Listing { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + when (scheme != null) { "\(encode(scheme)):" } +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. + when (hasAuthority()) { +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/hasAuthority(). + authority() +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/authority(). + } + path +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. + when (query != null) { "?\(query)" } +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. + when (fragment != null) { "#\(encode(fragment))" } +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/fragment. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/fragment. + }.join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + + /// Tells if [str] is a valid URI string. + const local isUriString = (str: String) -> +// ^^^^^^^^^^^ definition local isUriString_164 +// documentation +// > Tells if `str` is a valid URI string. +// ^^^ definition local str_165 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + str +// ^^^ reference local str_165 + .replaceAll(PERCENT_REGEX, "") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). +// ^^^^^^^^^^^^^ reference local PERCENT_REGEX_306 + .codePoints +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#codePoints. + .every((it) -> isUriSafe(it)) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^ definition local it_169 +// ^^^^^^^^^ reference local isUriSafe_175 +// ^^ reference local it_169 + + /// A string that has valid URI characters. + typealias UriString = String(isUriString) +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/UriString# +// documentation +// > A string that has valid URI characters. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^ reference local isUriString_164 + + // alphanumeric or !#$&'()*+,-./:;=?@_~ + const local function isUriSafe(codePoint: Int) = +// ^^^^^^^^^ definition local isUriSafe_175 +// ^^^^^^^^^ definition local codePoint_175 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + isAlphaNumeric(codePoint) +// ^^^^^^^^^^^^^^ reference local isAlphaNumeric_260 +// ^^^^^^^^^ reference local codePoint_175 + // ! + || codePoint == 33 +// ^^^^^^^^^ reference local codePoint_175 + // #$ + || codePoint.isBetween(35, 36) +// ^^^^^^^^^ reference local codePoint_175 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + // &'()*+,-./ + || codePoint.isBetween(38, 47) +// ^^^^^^^^^ reference local codePoint_175 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + // :; + || codePoint.isBetween(58, 59) +// ^^^^^^^^^ reference local codePoint_175 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + // = + || codePoint == 61 +// ^^^^^^^^^ reference local codePoint_175 + // ?@ + || codePoint.isBetween(63, 64) +// ^^^^^^^^^ reference local codePoint_175 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + // _ + || codePoint == 95 +// ^^^^^^^^^ reference local codePoint_175 + // ~ + || codePoint == 126 +// ^^^^^^^^^ reference local codePoint_175 + + // alphanumeric or !'()*-._~ + local function isUriComponentSafe(codePoint: Int) = +// ^^^^^^^^^^^^^^^^^^ definition local isUriComponentSafe_195 +// ^^^^^^^^^ definition local codePoint_195 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + isAlphaNumeric(codePoint) +// ^^^^^^^^^^^^^^ reference local isAlphaNumeric_260 +// ^^^^^^^^^ reference local codePoint_195 + // ! + || codePoint == 33 +// ^^^^^^^^^ reference local codePoint_195 + // '()* + || codePoint.isBetween(39, 42) +// ^^^^^^^^^ reference local codePoint_195 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + // -. + || codePoint.isBetween(45, 46) +// ^^^^^^^^^ reference local codePoint_195 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + // _ + || codePoint == 95 +// ^^^^^^^^^ reference local codePoint_195 + // ~ + || codePoint == 126 +// ^^^^^^^^^ reference local codePoint_195 + + local function getUtf8Bytes(codePoint: Int): List = +// ^^^^^^^^^^^^ definition local getUtf8Bytes_208 +// ^^^^^^^^^ definition local codePoint_208 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# + if (codePoint <= 0x7f) +// ^^^^^^^^^ reference local codePoint_208 + List(codePoint) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^^ reference local codePoint_208 + else if (codePoint <= 0x7ff) +// ^^^^^^^^^ reference local codePoint_208 + List( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + 0xc0.or(codePoint.shr(6)), +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^^^^^ reference local codePoint_208 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shr(). + 0x80.or(codePoint.and(0x3f)) +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^^^^^ reference local codePoint_208 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). + ) + else if (codePoint <= 0xffff) +// ^^^^^^^^^ reference local codePoint_208 + List( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + 0xe0.or(codePoint.shr(12)), +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^^^^^ reference local codePoint_208 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shr(). + 0x80.or(codePoint.shr(6).and(0x3f)), +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^^^^^ reference local codePoint_208 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shr(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). + 0x80.or(codePoint.and(0x3f)) +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^^^^^ reference local codePoint_208 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). + ) + else + List( +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + 0xf0.or(codePoint.shr(18)), +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^^^^^ reference local codePoint_208 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shr(). + 0x80.or(codePoint.shr(12).and(0x3f)), +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^^^^^ reference local codePoint_208 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shr(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). + 0x80.or(codePoint.shr(6).and(0x3f)), +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^^^^^ reference local codePoint_208 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shr(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). + 0x80.or(codePoint.and(0x3f)) +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^^^^^^^^ reference local codePoint_208 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). + ) + + /// Encode into percent encoding into utf-8 bytes. + /// + /// Facts: + /// ``` + /// percentEncode(" ".codePoints.first) == "%20" + /// percentEncode("/".codePoints.first) == "%2F" + /// ``` + local function percentEncode(codePoint: Int) = +// ^^^^^^^^^^^^^ definition local percentEncode_230 +// documentation +// > Encode into percent encoding into utf-8 bytes. +// > +// > Facts: +// > ``` +// > percentEncode(" ".codePoints.first) == "%20" +// > percentEncode("/".codePoints.first) == "%2F" +// > ``` +// ^^^^^^^^^ definition local codePoint_237 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + getUtf8Bytes(codePoint) +// ^^^^^^^^^^^^ reference local getUtf8Bytes_208 +// ^^^^^^^^^ reference local codePoint_237 + .map((it) -> "%" + it.toRadixString(16).toUpperCase().padStart(2, "0")) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local it_239 +// ^^ reference local it_239 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toUpperCase(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + .join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + local hexDigits = "0123456789ABCDEF" +// ^^^^^^^^^ definition local hexDigits_242 + + /// Facts: + /// ``` + /// getBytes("%20") == List(32) + /// getBytes("%7F") == List(127) + /// getBytes("%20%7F") == List(32, 127) + /// ``` + local function getBytes(str: String): List = +// ^^^^^^^^ definition local getBytes_244 +// documentation +// > Facts: +// > ``` +// > getBytes("%20") == List(32) +// > getBytes("%7F") == List(127) +// > getBytes("%20%7F") == List(32, 127) +// > ``` +// ^^^ definition local str_250 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# + str +// ^^^ reference local str_250 + .split("%") +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). + .drop(1) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). + .map((it) -> +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local it_254 + let (msb = hexDigits.indexOf(it[0].toUpperCase())) +// ^^^ definition local msb_255 +// ^^^^^^^^^ reference local hexDigits_242 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#indexOf(). +// ^^ reference local it_254 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toUpperCase(). + let (lsb = hexDigits.indexOf(it[1].toUpperCase())) +// ^^^ definition local lsb_256 +// ^^^^^^^^^ reference local hexDigits_242 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#indexOf(). +// ^^ reference local it_254 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toUpperCase(). + lsb + (msb * 16) +// ^^^ reference local lsb_256 +// ^^^ reference local msb_255 + ) + + const local function isAlphaNumeric(codePoint: Int) = +// ^^^^^^^^^^^^^^ definition local isAlphaNumeric_260 +// ^^^^^^^^^ definition local codePoint_260 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + codePoint.isBetween(48, 57) // 0-9 +// ^^^^^^^^^ reference local codePoint_260 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + || codePoint.isBetween(65, 90) // a-z +// ^^^^^^^^^ reference local codePoint_260 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + || codePoint.isBetween(97, 122) // A-Z +// ^^^^^^^^^ reference local codePoint_260 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#isBetween(). + + /// Encodes [str] using percent-encoding bytes to make it safe for the literal use as a URI. + /// + /// All characters except for alphanumeric chracters, and the chracters `!#$&'()*+,-./:;=?@_~` + /// are percent-encoded. + /// + /// Follows the rules for the `encodeURI` function as described by + /// [ECMA-262](https://262.ecma-international.org/5.1/#sec-15.1.3.3). + /// + /// Facts: + /// ``` + /// encode("https://example.com/some path/") == "https://example.com/some%20path" + /// ``` + /// + function encode(str: String): String = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// documentation +// > Encodes [`str`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.uri/URI.pkl#L278,C17) using percent-encoding bytes to make it safe for the literal use as a URI. +// > +// > All characters except for alphanumeric chracters, and the chracters `!#$&'()*+,-./:;=?@_~` +// > are percent-encoded. +// > +// > Follows the rules for the `encodeURI` function as described by +// > [ECMA-262](https://262.ecma-international.org/5.1/#sec-15.1.3.3). +// > +// > Facts: +// > ``` +// > encode("https://example.com/some path/") == "https://example.com/some%20path" +// > ``` +// ^^^ definition local str_278 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + str.codePoints +// ^^^ reference local str_278 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#codePoints. + .map((codePoint) -> +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^^^^^^ definition local codePoint_280 + if (isUriSafe(codePoint)) codePoint.toChar() +// ^^^^^^^^^ reference local isUriSafe_175 +// ^^^^^^^^^ reference local codePoint_280 +// ^^^^^^^^^ reference local codePoint_280 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toChar(). + else percentEncode(codePoint) +// ^^^^^^^^^^^^^ reference local percentEncode_230 +// ^^^^^^^^^ reference local codePoint_280 + ) + .join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + /// Encodes [str] using percent-encoding to make it safe to literal use as a URI component. + /// + /// All characters except for alphanumeric characters, and the characters `-_.!~*'()` are + /// percent-encoded. + /// + /// Follows the rules for the `encodeURIComponent` function as described by + /// [ECMA-262](https://262.ecma-international.org/5.1/#sec-15.1.3.4). + /// + /// Facts: + /// ``` + /// encodeComponent("https://example.com/some path") == "https%3A%2F%2example.com%2Fsome%20path" + /// ``` + function encodeComponent(str: String): String = +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encodeComponent(). +// documentation +// > Encodes [`str`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.uri/URI.pkl#L298,C26) using percent-encoding to make it safe to literal use as a URI component. +// > +// > All characters except for alphanumeric characters, and the characters `-_.!~*'()` are +// > percent-encoded. +// > +// > Follows the rules for the `encodeURIComponent` function as described by +// > [ECMA-262](https://262.ecma-international.org/5.1/#sec-15.1.3.4). +// > +// > Facts: +// > ``` +// > encodeComponent("https://example.com/some path") == "https%3A%2F%2example.com%2Fsome%20path" +// > ``` +// ^^^ definition local str_298 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + str.codePoints +// ^^^ reference local str_298 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#codePoints. + .map((codePoint) -> +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^^^^^^ definition local codePoint_300 + if (isUriComponentSafe(codePoint)) codePoint.toChar() +// ^^^^^^^^^^^^^^^^^^ reference local isUriComponentSafe_195 +// ^^^^^^^^^ reference local codePoint_300 +// ^^^^^^^^^ reference local codePoint_300 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toChar(). + else percentEncode(codePoint) +// ^^^^^^^^^^^^^ reference local percentEncode_230 +// ^^^^^^^^^ reference local codePoint_300 + ) + .join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + const local PERCENT_REGEX = Regex(#"(?:%[\da-fA-F]{2})+"#) +// ^^^^^^^^^^^^^ definition local PERCENT_REGEX_306 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + + /// Decodes [str] given a percent-encoded string. + function percentDecode(str: String): String = +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). +// documentation +// > Decodes [`str`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.uri/URI.pkl#L309,C24) given a percent-encoded string. +// ^^^ definition local str_309 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + str.replaceAllMapped(PERCENT_REGEX, (match) -> +// ^^^ reference local str_309 +// ^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAllMapped(). +// ^^^^^^^^^^^^^ reference local PERCENT_REGEX_306 +// ^^^^^ definition local match_310 + let (bytes = getBytes(match.value)) +// ^^^^^ definition local bytes_311 +// ^^^^^^^^ reference local getBytes_244 +// ^^^^^ reference local match_310 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + doPercentDecode(bytes) +// ^^^^^^^^^^^^^^^ reference local doPercentDecode_315 +// ^^^^^ reference local bytes_311 + ) + + local function doPercentDecode(bytes: List): String = _doPercentDecode(bytes, "") +// ^^^^^^^^^^^^^^^ definition local doPercentDecode_315 +// ^^^^^ definition local bytes_315 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^^ reference local _doPercentDecode_317 +// ^^^^^ reference local bytes_315 + + local function _doPercentDecode(bytes: List, ret: String) = +// ^^^^^^^^^^^^^^^^ definition local _doPercentDecode_317 +// ^^^^^ definition local bytes_317 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# +// ^^^ definition local ret_317 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (bytes.length == 0) ret +// ^^^^^ reference local bytes_317 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^ reference local ret_317 + else if (bytes[0] < 0x80) +// ^^^^^ reference local bytes_317 + _doPercentDecode(bytes.drop(1), ret + bytes[0].toChar()) +// ^^^^^^^^^^^^^^^^ reference local _doPercentDecode_317 +// ^^^^^ reference local bytes_317 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^ reference local ret_317 +// ^^^^^ reference local bytes_317 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toChar(). + else if (bytes[0] < 0xE0) +// ^^^^^ reference local bytes_317 + let (b0 = bytes[0].and(0x1f).shl(6)) +// ^^ definition local b0_322 +// ^^^^^ reference local bytes_317 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). + let (b1 = bytes[1].and(0x3f)) +// ^^ definition local b1_323 +// ^^^^^ reference local bytes_317 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). + _doPercentDecode(bytes.drop(2), ret + b0.or(b1).toChar()) +// ^^^^^^^^^^^^^^^^ reference local _doPercentDecode_317 +// ^^^^^ reference local bytes_317 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^ reference local ret_317 +// ^^ reference local b0_322 +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^ reference local b1_323 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toChar(). + else if (bytes[0] < 0xF0) +// ^^^^^ reference local bytes_317 + let (b0 = bytes[0].and(0xf).shl(12)) +// ^^ definition local b0_326 +// ^^^^^ reference local bytes_317 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). + let (b1 = bytes[1].and(0x3f).shl(6)) +// ^^ definition local b1_327 +// ^^^^^ reference local bytes_317 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). + let (b2 = bytes[2].and(0x3f)) +// ^^ definition local b2_328 +// ^^^^^ reference local bytes_317 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). + _doPercentDecode(bytes.drop(3), ret + b0.or(b1).or(b2).toChar()) +// ^^^^^^^^^^^^^^^^ reference local _doPercentDecode_317 +// ^^^^^ reference local bytes_317 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^ reference local ret_317 +// ^^ reference local b0_326 +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^ reference local b1_327 +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^ reference local b2_328 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toChar(). + else + let (b0 = bytes[0].and(0x7).shl(18)) +// ^^ definition local b0_331 +// ^^^^^ reference local bytes_317 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). + let (b1 = bytes[1].and(0x3f).shl(12)) +// ^^ definition local b1_332 +// ^^^^^ reference local bytes_317 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). + let (b2 = bytes[2].and(0x3f).shl(6)) +// ^^ definition local b2_333 +// ^^^^^ reference local bytes_317 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#shl(). + let (b3 = bytes[3].and(0x3f)) +// ^^ definition local b3_334 +// ^^^^^ reference local bytes_317 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#and(). + _doPercentDecode(bytes.drop(4), ret + b0.or(b1).or(b2).or(b3).toChar()) +// ^^^^^^^^^^^^^^^^ reference local _doPercentDecode_317 +// ^^^^^ reference local bytes_317 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#drop(). +// ^^^ reference local ret_317 +// ^^ reference local b0_331 +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^ reference local b1_332 +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^ reference local b2_333 +// ^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#or(). +// ^^ reference local b3_334 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toChar(). + + /// Regex to parse URI's. + /// + /// From . + // language=RegExp + local URI_REGEX: Regex = Regex(#""" +// ^^^^^^^^^ definition local URI_REGEX_337 +// documentation +// > Regex to parse URI's. +// > +// > From . +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? + """#) + + // language=RegExp + local AUTHORITY_REGEX: Regex = Regex(#""" +// ^^^^^^^^^^^^^^^ definition local AUTHORITY_REGEX_346 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + (?:([^@]+)@)?([^:]*)(?::(\d+))? + """#) + + // noinspection TypeMismatch + function parseAuthority(authority: String): Dynamic = +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parseAuthority(). +// ^^^^^^^^^ definition local authority_351 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + let (matches = AUTHORITY_REGEX.findMatchesIn(authority)) +// ^^^^^^^ definition local matches_352 +// ^^^^^^^^^^^^^^^ reference local AUTHORITY_REGEX_346 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex#findMatchesIn(). +// ^^^^^^^^^ reference local authority_351 + let (groups = matches[0].groups) +// ^^^^^^ definition local groups_353 +// ^^^^^^^ reference local matches_352 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. + new { + userInfo = groups.getOrNull(1)?.value?.ifNonNull((it) -> percentDecode(it)) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/userInfo. +// ^^^^^^ reference local groups_353 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#getOrNull(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_355 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). +// ^^ reference local it_355 + host = groups.getOrNull(2)?.value?.ifNonNull((it) -> percentDecode(it)) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/host. +// ^^^^^^ reference local groups_353 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#getOrNull(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_356 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). +// ^^ reference local it_356 + port = groups.getOrNull(3)?.value?.toInt() +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/port. +// ^^^^^^ reference local groups_353 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#getOrNull(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + } + + /// Parses the input string as a [URI]. + /// + /// If the input is not valid, returns `null`. + function parse(str: String): URI? = +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// documentation +// > Parses the input string as a [`URI`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.experimental.uri/URI.pkl#L21,C1). +// > +// > If the input is not valid, returns `null`. +// ^^^ definition local str_363 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + let (matches = URI_REGEX.findMatchesIn(str)) +// ^^^^^^^ definition local matches_364 +// ^^^^^^^^^ reference local URI_REGEX_337 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex#findMatchesIn(). +// ^^^ reference local str_363 + if (matches.isEmpty) null +// ^^^^^^^ reference local matches_364 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + else + let (groups = matches[0].groups) +// ^^^^^^ definition local groups_367 +// ^^^^^^^ reference local matches_364 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. + let (schemePart = groups.getOrNull(2)?.value) +// ^^^^^^^^^^ definition local schemePart_368 +// ^^^^^^ reference local groups_367 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#getOrNull(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + let (authorityPart = groups.getOrNull(4)?.value) +// ^^^^^^^^^^^^^ definition local authorityPart_369 +// ^^^^^^ reference local groups_367 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#getOrNull(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + let (pathPart = groups[5].value) +// ^^^^^^^^ definition local pathPart_370 +// ^^^^^^ reference local groups_367 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + let (queryPart = groups.getOrNull(7)?.value) +// ^^^^^^^^^ definition local queryPart_371 +// ^^^^^^ reference local groups_367 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#getOrNull(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + let (fragmentPart = groups.getOrNull(9)?.value) +// ^^^^^^^^^^^^ definition local fragmentPart_372 +// ^^^^^^ reference local groups_367 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#getOrNull(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + new URI { +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + when (schemePart != null) { +// ^^^^^^^^^^ reference local schemePart_368 + scheme = percentDecode(schemePart) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/scheme. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). +// ^^^^^^^^^^ reference local schemePart_368 + } + when (authorityPart != null) { +// ^^^^^^^^^^^^^ reference local authorityPart_369 + ...parseAuthority(authorityPart) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parseAuthority(). +// ^^^^^^^^^^^^^ reference local authorityPart_369 + } + path = pathPart +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/path. +// ^^^^^^^^ reference local pathPart_370 + query = queryPart +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/query. +// ^^^^^^^^^ reference local queryPart_371 + when (fragmentPart != null) { +// ^^^^^^^^^^^^ reference local fragmentPart_372 + fragment = percentDecode(fragmentPart) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/fragment. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). +// ^^^^^^^^^^^^ reference local fragmentPart_372 + } + } + diff --git a/pkl-pantrysnapshot/pkl.experimental.uri/tests/URI.pkl b/pkl-pantrysnapshot/pkl.experimental.uri/tests/URI.pkl new file mode 100755 index 00000000..1e54ab1c --- /dev/null +++ b/pkl-pantrysnapshot/pkl.experimental.uri/tests/URI.pkl @@ -0,0 +1,476 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.experimental.uri.tests.URI +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/ + + amends "pkl:test" + + import "../URI.pkl" + + local alphaLower = "abcdefghijklmnopqrstuvwxyz" +// ^^^^^^^^^^ definition local alphaLower_22 + local alphaUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +// ^^^^^^^^^^ definition local alphaUpper_23 + local nums = "0123456789" +// ^^^^ definition local nums_24 + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/facts. + ["encode"] { + URI.encode("https://example.com/some path") == "https://example.com/some%20path" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). + URI.encode(alphaLower) == alphaLower +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^^^^^^^ reference local alphaLower_22 +// ^^^^^^^^^^ reference local alphaLower_22 + URI.encode(alphaUpper) == alphaUpper +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^^^^^^^ reference local alphaUpper_23 +// ^^^^^^^^^^ reference local alphaUpper_23 + URI.encode(nums) == nums +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^ reference local nums_24 +// ^^^^ reference local nums_24 + + local safeChars = "!#$&'()*+,-./:;=?@_~" +// ^^^^^^^^^ definition local safeChars_33 + URI.encode(safeChars) == safeChars +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^^^^^^ reference local safeChars_33 +// ^^^^^^^^^ reference local safeChars_33 + URI.encode("\u{ffff}") == "%EF%BF%BF" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). + URI.encode("🏀") == "%F0%9F%8F%80" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). + URI.encode("\n") == "%0A" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). + } + ["encodeComponent"] { + URI.encodeComponent("https://example.com/some path") == "https%3A%2F%2Fexample.com%2Fsome%20path" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encodeComponent(). + URI.encode(alphaLower) == alphaLower +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^^^^^^^ reference local alphaLower_22 +// ^^^^^^^^^^ reference local alphaLower_22 + URI.encode(alphaUpper) == alphaUpper +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^^^^^^^ reference local alphaUpper_23 +// ^^^^^^^^^^ reference local alphaUpper_23 + URI.encode(nums) == nums +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^ reference local nums_24 +// ^^^^ reference local nums_24 + local safeChars = "-_.!~*'()" +// ^^^^^^^^^ definition local safeChars_44 + URI.encode(safeChars) == safeChars +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/encode(). +// ^^^^^^^^^ reference local safeChars_44 +// ^^^^^^^^^ reference local safeChars_44 + } + ["percentDecode"] { + URI.percentDecode("foo%20bar") == "foo bar" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). + URI.percentDecode("foo%20bar") == "foo bar" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). + URI.percentDecode("foo%20%20bar") == "foo bar" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). + URI.percentDecode("%F0%9F%8F%80") == "🏀" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). + URI.percentDecode("%C2%A3") == "£" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). + URI.percentDecode("%EF%BF%BF") == "\u{ffff}" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). + URI.percentDecode("%2Fbar%2Fbaz") == "/bar/baz" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/percentDecode(). + } + ["parse"] { + local uri1 = URI.parse("https://www.example.com") +// ^^^^ definition local uri1_57 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri1 == new URI { +// ^^^^ reference local uri1_57 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + scheme = "https" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/scheme. + host = "www.example.com" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/host. + path = "" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + } + uri1.pathSegments == List("") +// ^^^^ reference local uri1_57 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri2 = URI.parse("https://bilbo@www.example.com:1234/my/path?search=mysearch#fragment-value") +// ^^^^ definition local uri2_65 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri2 == new URI { +// ^^^^ reference local uri2_65 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + scheme = "https" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/scheme. + userInfo = "bilbo" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/userInfo. + host = "www.example.com" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/host. + port = 1234 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/port. + path = "/my/path" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + query = "search=mysearch" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/query. + fragment = "fragment-value" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/fragment. + } + uri2.pathSegments == List("my", "path") +// ^^^^ reference local uri2_65 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri3 = URI.parse("pkl:base?mybase") +// ^^^^ definition local uri3_77 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri3 == new URI { +// ^^^^ reference local uri3_77 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + scheme = "pkl" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/scheme. + path = "base" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + query = "mybase" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/query. + } + uri3.pathSegments == List("base") +// ^^^^ reference local uri3_77 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri4 = URI.parse("pkl:base?mybase#fragment") +// ^^^^ definition local uri4_85 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri4 == new URI { +// ^^^^ reference local uri4_85 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + scheme = "pkl" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/scheme. + path = "base" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + query = "mybase" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/query. + fragment = "fragment" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/fragment. + } + uri4.pathSegments == List("base") +// ^^^^ reference local uri4_85 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri5 = URI.parse("https://www.example.com/my%20path") +// ^^^^ definition local uri5_94 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri5 == new URI { +// ^^^^ reference local uri5_94 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + scheme = "https" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/scheme. + host = "www.example.com" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/host. + path = "/my%20path" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + } + uri5.pathSegments == List("my path") +// ^^^^ reference local uri5_94 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri6 = URI.parse("https://www.example.com/search?q=%F0%9F%8F%80") +// ^^^^ definition local uri6_102 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri6 == new URI { +// ^^^^ reference local uri6_102 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + scheme = "https" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/scheme. + host = "www.example.com" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/host. + path = "/search" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + query = "q=%F0%9F%8F%80" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/query. + } + uri6.pathSegments == List("search") +// ^^^^ reference local uri6_102 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri7 = URI.parse("myscheme:%F0%9F%8F%80#myfragment") +// ^^^^ definition local uri7_111 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri7 == new URI { +// ^^^^ reference local uri7_111 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + scheme = "myscheme" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/scheme. + path = "%F0%9F%8F%80" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + fragment = "myfragment" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/fragment. + } + uri7.pathSegments == List("🏀") +// ^^^^ reference local uri7_111 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri8 = URI.parse("file:/my%20file.txt") +// ^^^^ definition local uri8_119 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri8 == new URI { +// ^^^^ reference local uri8_119 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + scheme = "file" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/scheme. + path = "/my%20file.txt" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + } + uri8.pathSegments == List("my file.txt") +// ^^^^ reference local uri8_119 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri9 = URI.parse("file:///my%20file.txt") +// ^^^^ definition local uri9_126 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri9 == new URI { +// ^^^^ reference local uri9_126 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + scheme = "file" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/scheme. + path = "/my%20file.txt" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + host = "" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/host. + } + uri9.pathSegments == List("my file.txt") +// ^^^^ reference local uri9_126 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri10 = URI.parse("schemey:///first%2Fsegment/second") +// ^^^^^ definition local uri10_134 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri10 == new URI { +// ^^^^^ reference local uri10_134 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + scheme = "schemey" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/scheme. + path = "/first%2Fsegment/second" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + host = "" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/host. + } + uri10.pathSegments == List("first/segment", "second") +// ^^^^^ reference local uri10_134 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri11 = URI.parse("../bar/baz") +// ^^^^^ definition local uri11_142 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri11 == new URI { +// ^^^^^ reference local uri11_142 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + path = "../bar/baz" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + } + uri11.pathSegments == List("..", "bar", "baz") +// ^^^^^ reference local uri11_142 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri12 = URI.parse("//www.example.com/foo") +// ^^^^^ definition local uri12_148 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri12 == new URI { +// ^^^^^ reference local uri12_148 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + host = "www.example.com" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/host. + path = "/foo" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + } + uri12.pathSegments == List("foo") +// ^^^^^ reference local uri12_148 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local uri13 = URI.parse("#") +// ^^^^^ definition local uri13_155 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). + uri13 == new URI { +// ^^^^^ reference local uri13_155 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ + path = "" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/path. + fragment = "" +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `tests/URI.pkl`/fragment. + } + uri13.pathSegments == List("") +// ^^^^^ reference local uri13_155 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/pathSegments. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + } + ["toString()"] { + URI.parse("https://www.example.com").toString() == "https://www.example.com" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + URI.parse("https://bilbo@www.example.com:1234/my/path?search=mysearch#fragment-value").toString() == "https://bilbo@www.example.com:1234/my/path?search=mysearch#fragment-value" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + URI.parse("pkl:base?mybase").toString() == "pkl:base?mybase" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + URI.parse("pkl:base?mybase#fragment").toString() == "pkl:base?mybase#fragment" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + URI.parse("https://www.example.com/my%20path").toString() == "https://www.example.com/my%20path" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + URI.parse("https://www.example.com/search?q=%F0%9F%8F%80").toString() == "https://www.example.com/search?q=%F0%9F%8F%80" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + URI.parse("pkl:%F0%9F%8F%80#myfragment").toString() == "pkl:%F0%9F%8F%80#myfragment" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + URI.parse("file:/my%20file.txt").toString() == "file:/my%20file.txt" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + URI.parse("file:///my%20file.txt").toString() == "file:///my%20file.txt" +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + } + ["resolve"] { + URI.parse("schemey:/first/second/").resolve("../third").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + == "schemey:/first/third" + URI.parse("schemey:/first/second/").resolve("../../third").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + == "schemey:/third" + URI.parse("schemey:/first/second/").resolve("./").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + == "schemey:/first/second/" + URI.parse("schemey:/first/second").resolve("./").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + == "schemey:/first/" + URI.parse("schemey:/first/second/").resolve("/some/other/path").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + == "schemey:/some/other/path" + URI.parse("schemey:/first/second/").resolve("otherscheme:/some/other/path").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + == "otherscheme:/some/other/path" + URI.parse("schemey:/first/leaf").resolve("./").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + == "schemey:/first/" + URI.parse("schemey:/first/leaf").resolve("./second").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + == "schemey:/first/second" + URI.parse("https://www.example.com").resolve("some/relative/path").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + == "https://www.example.com/some/relative/path" + URI.parse("https://www.example.com").resolve("some/relative/path").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + == "https://www.example.com/some/relative/path" + URI.parse("https://www.example.com").resolve("//foo.com/some/relative/path").toString() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/ +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/parse(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/resolve(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri 1.0.3 `URI.pkl`/toString(). + == "https://foo.com/some/relative/path" + } + } + diff --git a/pkl-pantrysnapshot/pkl.lua/PklProject b/pkl-pantrysnapshot/pkl.lua/PklProject new file mode 100755 index 00000000..cf6cbb33 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.lua/PklProject @@ -0,0 +1,24 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A parser and renderer for a subset of [Lua](https://www.lua.org). + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 PklProject/package. + version = "1.1.1" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/pkl.lua/lua.pkl b/pkl-pantrysnapshot/pkl.lua/lua.pkl new file mode 100755 index 00000000..23a5962f --- /dev/null +++ b/pkl-pantrysnapshot/pkl.lua/lua.pkl @@ -0,0 +1,3193 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A [Parser] and [Renderer] for a subset of [Lua](https://www.lua.org). + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/minPklVersion. + module pkl.lua.lua +//^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ + + import "pkl:reflect" + import "pkl:base" + import "pkl:math" + import "lua.pkl" + + local const pathSpecRegex: Regex = let (prop = #"(?:[^\[\]^*.]+)"#) Regex(#""" +// ^^^^^^^^^^^^^ definition local pathSpecRegex_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex# +// ^^^^ definition local prop_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + (?x) + \^? + (?: + (?: + \#(prop) +// ^^^^ reference local prop_25 + | \* + | \[(?:\#(prop)|\*)\] +// ^^^^ reference local prop_25 + ) + (?: + \.\#(prop) +// ^^^^ reference local prop_25 + | \.\* + | \[(?:\#(prop)|\*)\] +// ^^^^ reference local prop_25 + )* + )? + """#) + local const pathSpecSplitRegex: Regex = Regex(#"\.|(?=\[)|(?<=[\^\]])"#) +// ^^^^^^^^^^^^^^^^^^ definition local pathSpecSplitRegex_41 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + + // Returns a [Prop] for string keys, otherwise [splatKey]. + local const function Prop(k: Any): Prop|Key = +// ^^^^ definition local Prop_44 +// ^ definition local k_44 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^ reference local Prop_47 +// ^^^ reference local Key_55 + if (k is String) new Prop { name = k } else splatKey +// ^ reference local k_44 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference local Prop_47 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/name. +// ^ reference local k_44 +// ^^^^^^^^ reference local splatKey_61 + + local class Prop { +// ^^^^ definition local Prop_47 + name: String +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Prop#name. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + // Returns a [Key] for string keys, otherwise [splatKey] + local const function Key(k: Any): Key = +// ^^^ definition local Key_52 +// ^ definition local k_52 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference local Key_55 + if (k is String) new Key { key = k } else splatKey +// ^ reference local k_52 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference local Key_55 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/key. +// ^ reference local k_52 +// ^^^^^^^^ reference local splatKey_61 + + local class Key { +// ^^^ definition local Key_55 + key: String +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Key#key. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + local typealias PathEntry = Prop|Key|"^" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^^ reference local Prop_47 +// ^^^ reference local Key_55 + + local const splatKey: Key = new Key { key = "*" } +// ^^^^^^^^ definition local splatKey_61 +// ^^^ reference local Key_55 +// ^^^ reference local Key_55 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/key. + + local const function splitPathConverters(converterMap: Map unknown>): List, (unknown) -> unknown>> = +// ^^^^^^^^^^^^^^^^^^^ definition local splitPathConverters_63 +// ^^^^^^^^^^^^ definition local converterMap_63 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# + converterMap +// ^^^^^^^^^^^^ reference local converterMap_63 + .filter((key, _) -> key is String) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^ definition local key_65 +// ^^^ reference local key_65 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + .mapKeys((key, _) -> +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#mapKeys(). +// ^^^ definition local key_66 + if (key.matches(pathSpecRegex)) +// ^^^ reference local key_66 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^^^^^^^^^ reference local pathSpecRegex_25 + if (key == "") List("^") else // PcfRenderer treats empty path as "^" +// ^^^ reference local key_66 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + key +// ^^^ reference local key_66 + .split(pathSpecSplitRegex) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^^^^^^^^^^^^^^^ reference local pathSpecSplitRegex_41 + .map((it) -> +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local it_71 + if (it == "^") "^" +// ^^ reference local it_71 + else if (it.startsWith("[")) new Key { key = it.substring(1, it.length-1) } +// ^^ reference local it_71 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^ reference local Key_55 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/key. +// ^^ reference local it_71 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^ reference local it_71 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + else new Prop { name = it }) +// ^^^^ reference local Prop_47 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/name. +// ^^ reference local it_71 + .reverse() +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#reverse(). + else throw("Converter path `\(key)` has invalid syntax.")) +// ^^^ reference local key_66 + .entries +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. + + /// A string that is a Lua reserved keyword. + /// + /// These strings are not allowed to be used as identifiers. + @AlsoKnownAs { names { "LuaKeyword" } } +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/AlsoKnownAs# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/names. + typealias Keyword = "and"|"break"|"do"|"else"|"elseif"|"end"|"false"|"for"|"function"|"goto"|"if"|"in"|"local"|"nil"|"not"|"or"|"repeat"|"return"|"then"|"true"|"until"|"while" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Keyword# +// documentation +// > A string that is a Lua reserved keyword. +// > +// > These strings are not allowed to be used as identifiers. + + /// Obsolete alias for [Keyword]. + @Deprecated { message = "Use [Keyword] instead."; replaceWith = "lua.Keyword"; since = "1.1.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Deprecated# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/message. +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/replaceWith. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/since. + typealias LuaKeyword = Keyword +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/LuaKeyword# +// documentation +// > Obsolete alias for [`Keyword`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L83,C11). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Keyword# + + /// A string that is a valid Lua identifier. + @AlsoKnownAs { names { "LuaIdentifier" } } +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/AlsoKnownAs# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/names. + typealias Identifier = String(matches(Regex("[a-zA-Z_][a-zA-Z0-9_]*")) && !(this is lua.Keyword)) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Identifier# +// documentation +// > A string that is a valid Lua identifier. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Keyword# + + /// Obsolete alias for [Identifier]. + @Deprecated { message = "Use [Identifier] instead."; replaceWith = "lua.Identifier"; since = "1.1.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Deprecated# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/message. +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/replaceWith. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/since. + typealias LuaIdentifier = Identifier +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/LuaIdentifier# +// documentation +// > Obsolete alias for [`Identifier`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L91,C11). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Identifier# + + /// Pkl representation of a Lua value. + typealias Value = Null|Boolean|Number|String|Listing|Dynamic|Mapping +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Value# +// documentation +// > Pkl representation of a Lua value. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + + /// Pkl representation of a valid Lua table key. + typealias TableKey = Boolean|Number(!isNaN)|String|Listing|Dynamic|Mapping +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/TableKey# +// documentation +// > Pkl representation of a valid Lua table key. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#isNaN. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + + // region Renderer + + /// Directs [Renderer] to output additional text [before] and/or [after] rendering a [value]. + @AlsoKnownAs { names { "LuaRenderDirective" } } +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/AlsoKnownAs# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective#names. + class RenderDirective { +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective# +// documentation +// > Directs [`Renderer`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L123,C7) to output additional text [`before`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L109,C3) and/or [`after`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L115,C3) rendering a [`value`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L112,C3). + /// The text to output before rendering [value]. + before: String? +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective#before. +// documentation +// > The text to output before rendering [`value`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L112,C3). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// The value to render. + value: Any +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective#value. +// documentation +// > The value to render. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + /// The text to output after rendering [value]. + after: String? +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective#after. +// documentation +// > The text to output after rendering [`value`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L112,C3). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// Obsolete alias for [RenderDirective]. + @Deprecated { message = "Use [RenderDirective] instead."; replaceWith = "lua.RenderDirective"; since = "1.1.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Deprecated# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/message. +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/replaceWith. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/since. + typealias LuaRenderDirective = RenderDirective +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/LuaRenderDirective# +// documentation +// > Obsolete alias for [`RenderDirective`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L107,C7). +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective# + + /// Renders values as Lua. + class Renderer extends ValueRenderer { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// documentation +// > Renders values as Lua. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer# + /// The characters to use for indenting output. Defaults to two spaces. + indent: String = " " +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#indent. +// documentation +// > The characters to use for indenting output. Defaults to two spaces. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Whether to skip rendering properties whose value is [null]. + /// + /// Note that due to language limitations, any entries in a [Dynamic] will be treated as + /// properties. + omitNullProperties: Boolean = false +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#omitNullProperties. +// documentation +// > Whether to skip rendering properties whose value is `null`. +// > +// > Note that due to language limitations, any entries in a [`Dynamic`](pkl-lsp://stdlib/base.pkl#L1808,C7) will be treated as +// > properties. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// The number of elements in a [Mapping] or [Listing] to render them multiline. + /// + /// The default value of `2` means a collection with a single element will be rendered in the + /// inline style, although any nested collections may be rendered in the multiline style. + /// + /// Note that [Map] and [List] are always rendered in the inline style. + multilineThreshold: Int = 2 +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#multilineThreshold. +// documentation +// > The number of elements in a [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7) or [`Listing`](pkl-lsp://stdlib/base.pkl#L1860,C7) to render them multiline. +// > +// > The default value of `2` means a collection with a single element will be rendered in the +// > inline style, although any nested collections may be rendered in the multiline style. +// > +// > Note that [`Map`](pkl-lsp://stdlib/base.pkl#L3286,C16) and [`List`](pkl-lsp://stdlib/base.pkl#L2873,C16) are always rendered in the inline style. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + + /// Value converters to apply before values are rendered. + /// + /// For more information see [ValueRenderer.converters]. Note that due to language limitations, + /// when rendering a [Dynamic], any entries with a [String] key will have converters applied as + /// though the entry was a property. This means paths like `x[foo]` only apply when rendering + /// a [Mapping], or when a class converter converts an entry key into a [String]. + converters: Mapping<(Class|String), (unknown) -> Any> +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#converters. +// documentation +// > Value converters to apply before values are rendered. +// > +// > For more information see [`ValueRenderer.converters`](pkl-lsp://stdlib/base.pkl#L308,C3). Note that due to language limitations, +// > when rendering a [`Dynamic`](pkl-lsp://stdlib/base.pkl#L1808,C7), any entries with a [`String`](pkl-lsp://stdlib/base.pkl#L1094,C16) key will have converters applied as +// > though the entry was a property. This means paths like `x`foo`` only apply when rendering +// > a [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7), or when a class converter converts an entry key into a [`String`](pkl-lsp://stdlib/base.pkl#L1094,C16). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + extension = "lua" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#extension. +// documentation +// > The file extension associated with this output format, +// > or `null` if this format does not have an extension. + + function renderValue(value: Any): String = +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// documentation +// > Renders [`value`](pkl-lsp://stdlib/base.pkl#L323,C33). +// ^^^^^ definition local value_151 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (path = List("^")) +// ^^^^ definition local path_152 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + render(convert(value, path), path, 0) +// ^^^^^^ reference local render_223 +// ^^^^^^^ reference local convert_197 +// ^^^^^ reference local value_151 +// ^^^^ reference local path_152 +// ^^^^ reference local path_152 + + function renderDocument(value: Any): String = +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// documentation +// > Renders [`value`](pkl-lsp://stdlib/base.pkl#L320,C36) as a complete document. +// > +// > Some renderers impose restrictions on which types of values can be rendered as document. +// > +// > A typical implementation of this method renders a document header/footer +// > and otherwise delegates to [`renderValue()`](pkl-lsp://stdlib/base.pkl#L323,C3). +// ^^^^^ definition local value_155 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (path = List("^")) +// ^^^^ definition local path_156 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + let (value = convert(value, path)) +// ^^^^^ definition local value_157 +// ^^^^^^^ reference local convert_197 +// ^^^^^ reference local value_155 +// ^^^^ reference local path_156 + if (value is base.RenderDirective) "\(value.text)\n" +// ^^^^^ reference local value_157 +// ^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RenderDirective# +// ^^^^^ reference local value_157 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RenderDirective#text. + else if (value is RenderDirective) "\(value.before ?? "")\(render(value.value, path, 0))\(value.after ?? "")\n" +// ^^^^^ reference local value_157 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective# +// ^^^^^ reference local value_157 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective#before. +// ^^^^^^ reference local render_223 +// ^^^^^ reference local value_157 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective#value. +// ^^^^ reference local path_156 +// ^^^^^ reference local value_157 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective#after. + else if (value is Dynamic|Typed) +// ^^^^^ reference local value_157 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# + value.toMap().fold("", (acc, k, v) -> +// ^^^^^ reference local value_157 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#fold(). +// ^^^ definition local acc_161 +// ^ definition local k_161 +// ^ definition local v_161 + let (isProp = k is String) +// ^^^^^^ definition local isProp_162 +// ^ reference local k_161 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (k = if (isProp) k else convert(k, null)) +// ^ definition local k_163 +// ^^^^^^ reference local isProp_162 +// ^ reference local k_161 +// ^^^^^^^ reference local convert_197 +// ^ reference local k_161 + let (path = path.add(if (isProp) Prop(k) else Key(k))) +// ^^^^ definition local path_164 +// ^^^^ reference local path_156 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^^ reference local isProp_162 +// ^^^^ reference local Prop_44 +// ^ reference local k_163 +// ^^^ reference local Key_52 +// ^ reference local k_163 + let (v = convert(v, path)) +// ^ definition local v_165 +// ^^^^^^^ reference local convert_197 +// ^ reference local v_161 +// ^^^^ reference local path_164 + if (omitNullProperties && v == null && isProp) acc +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#omitNullProperties. +// ^ reference local v_165 +// ^^^^^^ reference local isProp_162 +// ^^^ reference local acc_161 + else acc + "\(renderKey(k, "_ENV")) = \(render(v, path, 0))\n") +// ^^^ reference local acc_161 +// ^^^^^^^^^ reference local renderKey_236 +// ^ reference local k_163 +// ^^^^^^ reference local render_223 +// ^ reference local v_165 +// ^^^^ reference local path_164 + + (if (value is Dynamic) value.toList() else List()).foldIndexed("", (idx, acc, v) -> +// ^^^^^ reference local value_157 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ reference local value_157 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#foldIndexed(). +// ^^^ definition local idx_168 +// ^^^ definition local acc_168 +// ^ definition local v_168 + let (path = path.add(splatKey)) +// ^^^^ definition local path_169 +// ^^^^ reference local path_156 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^^^^ reference local splatKey_61 + let (v = convert(v, path)) +// ^ definition local v_170 +// ^^^^^^^ reference local convert_197 +// ^ reference local v_168 +// ^^^^ reference local path_169 + // remember, Lua indexes are 1-based + acc + "_ENV[\(idx+1)] = \(render(v, path, 0))\n") +// ^^^ reference local acc_168 +// ^^^ reference local idx_168 +// ^^^^^^ reference local render_223 +// ^ reference local v_170 +// ^^^^ reference local path_169 + else if (value is Mapping|Map) +// ^^^^^ reference local value_157 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# + value.fold("", (acc, k, v) -> +// ^^^^^ reference local value_157 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#fold(). +// ^^^ definition local acc_174 +// ^ definition local k_174 +// ^ definition local v_174 + let (k = convert(k, null)) +// ^ definition local k_175 +// ^^^^^^^ reference local convert_197 +// ^ reference local k_174 + let (path = path.add(Key(k))) +// ^^^^ definition local path_176 +// ^^^^ reference local path_156 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local Key_52 +// ^ reference local k_175 + let (v = convert(v, path)) +// ^ definition local v_177 +// ^^^^^^^ reference local convert_197 +// ^ reference local v_174 +// ^^^^ reference local path_176 + acc + "\(renderKey(k, "_ENV")) = \(render(v, path, 0))\n") +// ^^^ reference local acc_174 +// ^^^^^^^^^ reference local renderKey_236 +// ^ reference local k_175 +// ^^^^^^ reference local render_223 +// ^ reference local v_177 +// ^^^^ reference local path_176 + else throw("The top-level value of a Lua document must have type `Typed`, `Dynamic`, `Mapping`, or `Map`, but got type `\(value.getClass())`") +// ^^^^^ reference local value_157 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + + // region Converters + + local converterMap = converters.toMap() +// ^^^^^^^^^^^^ definition local converterMap_183 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#converters. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + + // path specs are already in reversed order + local pathConverters: List,(unknown) -> Any>> = +// ^^^^^^^^^^^^^^ definition local pathConverters_186 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + splitPathConverters(converterMap) +// ^^^^^^^^^^^^^^^^^^^ reference local splitPathConverters_63 +// ^^^^^^^^^^^^ reference local converterMap_183 + + // [true] if the converters define any class converters. + // For the time being this is limited to any subclasses of [Typed], as this matches current + // [PcfRenderer] behavior. I understand this is a Pkl bug and e.g. [Number] should match [Int], + // but we'll match the bug for now for performance reasons. + local hasTypedConverters: Boolean = +// ^^^^^^^^^^^^^^^^^^ definition local hasTypedConverters_193 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + let (typedClass = reflect.Class(Typed)) +// ^^^^^^^^^^ definition local typedClass_194 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# + converterMap.any((k,_) -> k is Class && reflect.Class(k).isSubclassOf(typedClass)) +// ^^^^^^^^^^^^ reference local converterMap_183 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#any(). +// ^ definition local k_195 +// ^ reference local k_195 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^ reference local k_195 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#isSubclassOf(). +// ^^^^^^^^^^ reference local typedClass_194 + + local function convert(value: Any, path: List?): Any = +// ^^^^^^^ definition local convert_197 +// ^^^^^ definition local value_197 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^ definition local path_197 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + let (f = +// ^ definition local f_198 + if (path != null && !pathConverters.isEmpty) +// ^^^^ reference local path_197 +// ^^^^^^^^^^^^^^ reference local pathConverters_186 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + let (path = path.reverse()) +// ^^^^ definition local path_200 +// ^^^^ reference local path_197 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#reverse(). + pathConverters.findOrNull((p) -> comparePaths(path, p.key))?.value +// ^^^^^^^^^^^^^^ reference local pathConverters_186 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#findOrNull(). +// ^ definition local p_201 +// ^^^^^^^^^^^^ reference local comparePaths_209 +// ^^^^ reference local path_200 +// ^ reference local p_201 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#key. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#value. + else null) + let (klass = value.getClass()) +// ^^^^^ definition local klass_203 +// ^^^^^ reference local value_197 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + let (f = f ?? converterMap.getOrNull(klass)) +// ^ definition local f_204 +// ^ reference local f_198 +// ^^^^^^^^^^^^ reference local converterMap_183 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#getOrNull(). +// ^^^^^ reference local klass_203 + let (f = f ?? if (hasTypedConverters && value is Typed) findTypedConverter(reflect.Class(klass).superclass) else null) // find superclass converters +// ^ definition local f_205 +// ^ reference local f_204 +// ^^^^^^^^^^^^^^^^^^ reference local hasTypedConverters_193 +// ^^^^^ reference local value_197 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^^^^^^^^^^^^^^^ reference local findTypedConverter_216 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class(). +// ^^^^^ reference local klass_203 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#superclass. + if (f != null) f.apply(value) else value +// ^ reference local f_205 +// ^ reference local f_205 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^ reference local value_197 +// ^^^^^ reference local value_197 + + // the path and spec must already be reversed + local function comparePaths(path: List, pathSpec: List): Boolean = +// ^^^^^^^^^^^^ definition local comparePaths_209 +// ^^^^ definition local path_209 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^^^^^^ definition local pathSpec_209 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + path.length >= pathSpec.length && path.zip(pathSpec).every((p) -> +// ^^^^ reference local path_209 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^^^^ reference local pathSpec_209 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^ reference local path_209 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#zip(). +// ^^^^^^^^ reference local pathSpec_209 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^ definition local p_210 + if (p.second is Prop && p.second.name == "*") p.first is Prop +// ^ reference local p_210 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^^ reference local Prop_47 +// ^ reference local p_210 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Prop#name. +// ^ reference local p_210 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^^^^ reference local Prop_47 + else if (p.second is Key && p.second.key == "*") p.first is Key +// ^ reference local p_210 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^ reference local Key_55 +// ^ reference local p_210 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Key#key. +// ^ reference local p_210 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^^^ reference local Key_55 + else p.first == p.second +// ^ reference local p_210 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^ reference local p_210 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + ) + + local function findTypedConverter(klass: reflect.Class?): ((unknown) -> Any)? = +// ^^^^^^^^^^^^^^^^^^ definition local findTypedConverter_216 +// ^^^^^ definition local klass_216 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + if (klass == null) null +// ^^^^^ reference local klass_216 + else converters.getOrNull(klass.reflectee) ?? findTypedConverter(klass.superclass) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#converters. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^ reference local klass_216 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#reflectee. +// ^^^^^^^^^^^^^^^^^^ reference local findTypedConverter_216 +// ^^^^^ reference local klass_216 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Class#superclass. + + // endregion + // region Rendering functions + + local function render(value: Any, path: List, level: UInt?): String = +// ^^^^^^ definition local render_223 +// ^^^^^ definition local value_223 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^ definition local path_223 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^^^ definition local level_223 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (value is String) renderString(value, level != null) +// ^^^^^ reference local value_223 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^ reference local renderString_243 +// ^^^^^ reference local value_223 +// ^^^^^ reference local level_223 + else if (value is Boolean) value.toString() +// ^^^^^ reference local value_223 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^ reference local value_223 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#toString(). + else if (value is Number) renderNumber(value) +// ^^^^^ reference local value_223 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^^^^^^ reference local renderNumber_271 +// ^^^^^ reference local value_223 + else if (value is Null) "nil" +// ^^^^^ reference local value_223 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# + else if (value is Mapping|Map) renderMap(value, path, level) +// ^^^^^ reference local value_223 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^^^ reference local renderMap_276 +// ^^^^^ reference local value_223 +// ^^^^ reference local path_223 +// ^^^^^ reference local level_223 + else if (value is Listing|List) renderList(value, path, level) +// ^^^^^ reference local value_223 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^^ reference local renderList_291 +// ^^^^^ reference local value_223 +// ^^^^ reference local path_223 +// ^^^^^ reference local level_223 + else if (value is Dynamic) renderDynamic(value, path, level) +// ^^^^^ reference local value_223 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^^^^ reference local renderDynamic_302 +// ^^^^^ reference local value_223 +// ^^^^ reference local path_223 +// ^^^^^ reference local level_223 + else if (value is base.RenderDirective) value.text +// ^^^^^ reference local value_223 +// ^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RenderDirective# +// ^^^^^ reference local value_223 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RenderDirective#text. + else if (value is RenderDirective) "\(value.before ?? "")\(render(value.value, path, level))\(value.after ?? "")" +// ^^^^^ reference local value_223 +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective# +// ^^^^^ reference local value_223 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective#before. +// ^^^^^^ reference local render_223 +// ^^^^^ reference local value_223 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective#value. +// ^^^^ reference local path_223 +// ^^^^^ reference local level_223 +// ^^^^^ reference local value_223 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective#after. + else if (value is Typed) renderDynamic(value, path, level) +// ^^^^^ reference local value_223 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^^^^^^^^^^ reference local renderDynamic_302 +// ^^^^^ reference local value_223 +// ^^^^ reference local path_223 +// ^^^^^ reference local level_223 + else throw("Cannot render value of type `\(value.getClass())` as Lua.\nValue: \(value)") +// ^^^^^ reference local value_223 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^ reference local value_223 + + local function renderKey(key: Any, prefix: String): String = +// ^^^^^^^^^ definition local renderKey_236 +// ^^^ definition local key_236 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^ definition local prefix_236 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (key is Null) throw("Lua table keys cannot be null") +// ^^^ reference local key_236 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Null# + else if (key is Number && key.isNaN) throw("Lua table keys cannot be NaN") +// ^^^ reference local key_236 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^ reference local key_236 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#isNaN. + else if (key is Identifier) key +// ^^^ reference local key_236 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Identifier# +// ^^^ reference local key_236 + else if (key is base.RenderDirective) key.text +// ^^^ reference local key_236 +// ^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RenderDirective# +// ^^^ reference local key_236 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RenderDirective#text. + else "\(prefix)[\(render(key, List(), null))]" +// ^^^^^^ reference local prefix_236 +// ^^^^^^ reference local render_223 +// ^^^ reference local key_236 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + + local function renderString(value: String, multiline: Boolean): String = +// ^^^^^^^^^^^^ definition local renderString_243 +// ^^^^^ definition local value_243 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ definition local multiline_243 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (delim = if (value.contains("\"") && !value.contains("'")) "'" else "\"") +// ^^^^^ definition local delim_244 +// ^^^^^ reference local value_243 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). +// ^^^^^ reference local value_243 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + if (multiline && value.contains(Regex(#"[^\n]\n++[^\n]"#))) +// ^^^^^^^^^ reference local multiline_243 +// ^^^^^ reference local value_243 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + // there are interior newlines, we'll do a multiline style + if (value.contains(Regex(#"[\p{Cntrl}\#(delim)&&[^\n ]]"#))) +// ^^^^^ reference local value_243 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^ reference local delim_244 + // we need escapes, we'll do multiline with escaped newlines + "\(delim)\(escapeString(value, delim, true))\(delim)" +// ^^^^^ reference local delim_244 +// ^^^^^^^^^^^^ reference local escapeString_259 +// ^^^^^ reference local value_243 +// ^^^^^ reference local delim_244 +// ^^^^^ reference local delim_244 + else + IntSeq(0, 10) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). + .map((n) -> "=".repeat(n)) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq#map(). +// ^ definition local n_252 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^ reference local n_252 + .findOrNull((eq) -> !value.contains("]\(eq)]")) +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#findOrNull(). +// ^^ definition local eq_253 +// ^^^^^ reference local value_243 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). +// ^^ reference local eq_253 + .ifNonNull((eq) -> "[\(eq)[\n\(value)]\(eq)]") +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local eq_254 +// ^^ reference local eq_254 +// ^^^^^ reference local value_243 +// ^^ reference local eq_254 + // if we can't find a good ]==] ending, use the other style + ?? "\(delim)\(escapeString(value, delim, true))\(delim)" +// ^^^^^ reference local delim_244 +// ^^^^^^^^^^^^ reference local escapeString_259 +// ^^^^^ reference local value_243 +// ^^^^^ reference local delim_244 +// ^^^^^ reference local delim_244 + else "\(delim)\(escapeString(value, delim, false))\(delim)" +// ^^^^^ reference local delim_244 +// ^^^^^^^^^^^^ reference local escapeString_259 +// ^^^^^ reference local value_243 +// ^^^^^ reference local delim_244 +// ^^^^^ reference local delim_244 + + local function escapeString(value: String, delim: String, multiline: Boolean): String = +// ^^^^^^^^^^^^ definition local escapeString_259 +// ^^^^^ definition local value_259 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local delim_259 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^ definition local multiline_259 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + value.replaceAllMapped(Regex(#"[\p{Cntrl}\\\#(delim)&&[^ ]]"#), (match) -> +// ^^^^^ reference local value_259 +// ^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAllMapped(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^ reference local delim_259 +// ^^^^^ definition local match_260 + if (match.value == "\u{7}") "\\a" +// ^^^^^ reference local match_260 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + else if (match.value == "\u{8}") "\\b" +// ^^^^^ reference local match_260 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + else if (match.value == "\u{c}") "\\f" +// ^^^^^ reference local match_260 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + else if (match.value == "\n") if (multiline) "\\\n" else "\\n" +// ^^^^^ reference local match_260 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^ reference local multiline_259 + else if (match.value == "\r") "\\r" +// ^^^^^ reference local match_260 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + else if (match.value == "\t") "\\t" +// ^^^^^ reference local match_260 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + else if (match.value == "\u{b}") "\\v" +// ^^^^^ reference local match_260 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + else if (match.value == delim) "\\\(delim)" +// ^^^^^ reference local match_260 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^ reference local delim_259 +// ^^^^^ reference local delim_259 + else "\\u{\(match.value.codePoints.first.toRadixString(16))}") +// ^^^^^ reference local match_260 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#codePoints. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#first. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). + + local function renderNumber(value: Number): String = +// ^^^^^^^^^^^^ definition local renderNumber_271 +// ^^^^^ definition local value_271 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (value.isNaN) "(0/0)" +// ^^^^^ reference local value_271 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#isNaN. + else if (value.isInfinite) "(\(value.sign.toInt())/0)" +// ^^^^^ reference local value_271 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#isInfinite. +// ^^^^^ reference local value_271 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#sign. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#toInt(). + else value.toString() +// ^^^^^ reference local value_271 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#toString(). + + local function renderMap(value: Mapping|Map, path: List, level: UInt?): String = +// ^^^^^^^^^ definition local renderMap_276 +// ^^^^^ definition local value_276 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^ definition local path_276 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^^^ definition local level_276 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (value.isEmpty) "{}" else +// ^^^^^ reference local value_276 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#isEmpty. + let (map = value.toMap()) +// ^^^ definition local map_278 +// ^^^^^ reference local value_276 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMap(). + let (multiline = map.length >= multilineThreshold && level != null && value is Mapping) +// ^^^^^^^^^ definition local multiline_279 +// ^^^ reference local map_278 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#length. +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#multilineThreshold. +// ^^^^^ reference local level_276 +// ^^^^^ reference local value_276 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + let (level_ = if (multiline) level!! + 1 else level) +// ^^^^^^ definition local level__280 +// ^^^^^^^^^ reference local multiline_279 +// ^^^^^ reference local level_276 +// ^^^^^ reference local level_276 + (if (multiline) "{\n\(indent.repeat(level_!!))" else "{ ") +// ^^^^^^^^^ reference local multiline_279 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^^ reference local level__280 + + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + for (k,v in map) { +// ^ definition local k_283 +// ^ definition local v_283 +// ^^^ reference local map_278 + let (k = convert(k, null)) +// ^ definition local k_284 +// ^^^^^^^ reference local convert_197 +// ^ reference local k_283 + let (path = path.add(Key(k))) +// ^^^^ definition local path_285 +// ^^^^ reference local path_276 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^ reference local Key_52 +// ^ reference local k_284 + "\(renderKey(k, "")) = \(render(convert(v, path), path, level_));" +// ^^^^^^^^^ reference local renderKey_236 +// ^ reference local k_284 +// ^^^^^^ reference local render_223 +// ^^^^^^^ reference local convert_197 +// ^ reference local v_283 +// ^^^^ reference local path_285 +// ^^^^ reference local path_285 +// ^^^^^^ reference local level__280 + } + }.join(if (multiline) "\n\(indent.repeat(level_!!))" else " ") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). +// ^^^^^^^^^ reference local multiline_279 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^^ reference local level__280 + + if (multiline) "\n\(indent.repeat(level!!))}" else " }" +// ^^^^^^^^^ reference local multiline_279 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^ reference local level_276 + + local function renderList(value: Listing|List, path: List, level: UInt?): String = +// ^^^^^^^^^^ definition local renderList_291 +// ^^^^^ definition local value_291 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^ definition local path_291 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^^^ definition local level_291 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (value.isEmpty) "{}" else +// ^^^^^ reference local value_291 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + let (path = path.add(splatKey)) +// ^^^^ definition local path_293 +// ^^^^ reference local path_291 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^^^^ reference local splatKey_61 + let (multiline = value.length >= multilineThreshold && level != null && !(value is List)) +// ^^^^^^^^^ definition local multiline_294 +// ^^^^^ reference local value_291 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#multilineThreshold. +// ^^^^^ reference local level_291 +// ^^^^^ reference local value_291 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# + let (level_ = if (multiline) level!! + 1 else level) +// ^^^^^^ definition local level__295 +// ^^^^^^^^^ reference local multiline_294 +// ^^^^^ reference local level_291 +// ^^^^^ reference local level_291 + (if (multiline) "{\n\(indent.repeat(level_!!))" else "{ ") +// ^^^^^^^^^ reference local multiline_294 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^^ reference local level__295 + + value.toList() +// ^^^^^ reference local value_291 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toList(). + .map((it) -> render(convert(it, path), path, level_)) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local it_298 +// ^^^^^^ reference local render_223 +// ^^^^^^^ reference local convert_197 +// ^^ reference local it_298 +// ^^^^ reference local path_293 +// ^^^^ reference local path_293 +// ^^^^^^ reference local level__295 + .join(if (multiline) ",\n\(indent.repeat(level_!!))" else ", ") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). +// ^^^^^^^^^ reference local multiline_294 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^^ reference local level__295 + + if (multiline) "\n\(indent.repeat(level!!))}" else " }" +// ^^^^^^^^^ reference local multiline_294 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^ reference local level_291 + + local function renderDynamic(value: Dynamic|Typed, path: List, level: UInt?): String = +// ^^^^^^^^^^^^^ definition local renderDynamic_302 +// ^^^^^ definition local value_302 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^^ definition local path_302 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^^^ definition local level_302 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (list = if (value is Dynamic) value.toList() else List()) +// ^^^^ definition local list_303 +// ^^^^^ reference local value_302 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ reference local value_302 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + let (map = value.toMap()) +// ^^^ definition local map_304 +// ^^^^^ reference local value_302 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). + // note: Map.keys.toList() is O(1), other ways of converting are O(n) (as of Pkl 0.25.3) + let (entries = map.keys.toList().mapNonNull((k_) -> +// ^^^^^^^ definition local entries_306 +// ^^^ reference local map_304 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#keys. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Set#toList(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#mapNonNull(). +// ^^ definition local k__306 + let (isProp = k_ is String) +// ^^^^^^ definition local isProp_307 +// ^^ reference local k__306 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (k = if (isProp) k_ else convert(k_, null)) +// ^ definition local k_308 +// ^^^^^^ reference local isProp_307 +// ^^ reference local k__306 +// ^^^^^^^ reference local convert_197 +// ^^ reference local k__306 + let (path = path.add(if (isProp) Prop(k) else Key(k))) +// ^^^^ definition local path_309 +// ^^^^ reference local path_302 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^^ reference local isProp_307 +// ^^^^ reference local Prop_44 +// ^ reference local k_308 +// ^^^ reference local Key_52 +// ^ reference local k_308 + let (v = convert(map[k_], path)) +// ^ definition local v_310 +// ^^^^^^^ reference local convert_197 +// ^^^ reference local map_304 +// ^^ reference local k__306 +// ^^^^ reference local path_309 + if (omitNullProperties && v == null && isProp) null +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#omitNullProperties. +// ^ reference local v_310 +// ^^^^^^ reference local isProp_307 + else Pair(k, Pair(path, v)) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^ reference local k_308 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^^^ reference local path_309 +// ^ reference local v_310 + )) + if (entries.isEmpty && list.isEmpty) "{}" else +// ^^^^^^^ reference local entries_306 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^^ reference local list_303 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + let (multiline = entries.length + list.length >= multilineThreshold && level != null) +// ^^^^^^^^^ definition local multiline_315 +// ^^^^^^^ reference local entries_306 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^ reference local list_303 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#multilineThreshold. +// ^^^^^ reference local level_302 + let (level_ = if (multiline) level!! + 1 else level) +// ^^^^^^ definition local level__316 +// ^^^^^^^^^ reference local multiline_315 +// ^^^^^ reference local level_302 +// ^^^^^ reference local level_302 + let (listPath = if (list.isEmpty) path else path.add(splatKey)) +// ^^^^^^^^ definition local listPath_317 +// ^^^^ reference local list_303 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^^ reference local path_302 +// ^^^^ reference local path_302 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^^^^ reference local splatKey_61 + (if (multiline) "{\n\(indent.repeat(level_!!))" else "{ ") +// ^^^^^^^^^ reference local multiline_315 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^^ reference local level__316 + + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + for (kpv in entries) { // kpv = Pair(key, Pair(path, value)) +// ^^^ definition local kpv_320 +// ^^^^^^^ reference local entries_306 + "\(renderKey(kpv.key, "")) = \(render(kpv.value.value, kpv.value.key, level_));" +// ^^^^^^^^^ reference local renderKey_236 +// ^^^ reference local kpv_320 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#key. +// ^^^^^^ reference local render_223 +// ^^^ reference local kpv_320 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#value. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#value. +// ^^^ reference local kpv_320 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#value. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#key. +// ^^^^^^ reference local level__316 + } + for (i,elt in list) { +// ^ definition local i_323 +// ^^^ definition local elt_323 +// ^^^^ reference local list_303 + when (i < list.lastIndex) { +// ^ reference local i_323 +// ^^^^ reference local list_303 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#lastIndex. + "\(render(convert(elt, listPath), listPath, level_))," +// ^^^^^^ reference local render_223 +// ^^^^^^^ reference local convert_197 +// ^^^ reference local elt_323 +// ^^^^^^^^ reference local listPath_317 +// ^^^^^^^^ reference local listPath_317 +// ^^^^^^ reference local level__316 + } else { + render(convert(list.last, listPath), listPath, level_) +// ^^^^^^ reference local render_223 +// ^^^^^^^ reference local convert_197 +// ^^^^ reference local list_303 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. +// ^^^^^^^^ reference local listPath_317 +// ^^^^^^^^ reference local listPath_317 +// ^^^^^^ reference local level__316 + } + } + }.join(if (multiline) "\n\(indent.repeat(level_!!))" else " ") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). +// ^^^^^^^^^ reference local multiline_315 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^^ reference local level__316 + + if (multiline) "\n\(indent.repeat(level!!))}" else " }" +// ^^^^^^^^^ reference local multiline_315 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^ reference local level_302 + + // endregion + } + + // endregion + // region Parser + + /// A parser for a strict subset of Lua. + /// + /// This parser can handle Lua files that consist of comments and `key=value` lines, where the key is a Lua identifier + /// and the value is a literal string, number, boolean, `nil`, or table. Expressions are not supported. At the top level + /// the key cannot be the identifier `_ENV` unless it is followed by a subscript expression, as in `_ENV[key]=value`. + /// An `_ENV` subscript like this allows the top-level to contain keys that are not Lua identifiers. + /// + /// When parsing nested tables, tables using key/value syntax (`{ [key] = value; … }`) will be parsed as list elements + /// if the key is integral and equal to the next unused index, otherwise they will be treated as map entries. Be aware + /// that the order of keys is important here; `{ [0] = "a"; [1] = "b"; [2] = "c" }` will be parsed as a list whereas + /// `{ [2] = "c"; [1] = "b"; [0] = "a" }` will be parsed as a map despite being equivalent Lua tables. See [useDynamic] + /// for details on the type used to represent nested tables. + /// + /// When parsing `_ENV[key]=value` statements at the top-level, if the subscript key is an integral value and + /// [useDynamic] is [true] then it will be parsed as a list element in the same fashion as nested tables. However if + /// [useDynamic] is [false] then integral keys will not be treated any differently than other keys. + /// + /// Lua values are mapped to Pkl values as follows: + /// + /// **Lua type** | **Pkl type** + /// -------------|------------- + /// nil | [Null] + /// boolean | [Boolean] + /// number | [Number] + /// string | [String] + /// table | [Dynamic] or [Mapping]/[Listing] depending on [Parser.useDynamic] + /// + /// # Example + /// + /// This is a sample Lua file that can be parsed with this Parser. + /// ```lua + /// --[[ + /// This file has a header comment. + /// ]] + /// foo="bar" + /// count=2 + /// -- line comment here + /// enable=true + /// frob=nil + /// ports={80, 443} + /// ips={ + /// localhost = "127.0.0.1"; + /// ["example.com"] = "93.184.215.14"; + /// } + /// _ENV[" "]="space" + /// ``` + class Parser { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser# +// documentation +// > A parser for a strict subset of Lua. +// > +// > This parser can handle Lua files that consist of comments and `key=value` lines, where the key is a Lua identifier +// > and the value is a literal string, number, boolean, `nil`, or table. Expressions are not supported. At the top level +// > the key cannot be the identifier `_ENV` unless it is followed by a subscript expression, as in `_ENV`key`=value`. +// > An `_ENV` subscript like this allows the top-level to contain keys that are not Lua identifiers. +// > +// > When parsing nested tables, tables using key/value syntax (`{ `key` = value; … }`) will be parsed as list elements +// > if the key is integral and equal to the next unused index, otherwise they will be treated as map entries. Be aware +// > that the order of keys is important here; `{ `0` = "a"; `1` = "b"; `2` = "c" }` will be parsed as a list whereas +// > `{ `2` = "c"; `1` = "b"; `0` = "a" }` will be parsed as a map despite being equivalent Lua tables. See [`useDynamic`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L395,C3) +// > for details on the type used to represent nested tables. +// > +// > When parsing `_ENV`key`=value` statements at the top-level, if the subscript key is an integral value and +// > [`useDynamic`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L395,C3) is `true` then it will be parsed as a list element in the same fashion as nested tables. However if +// > [`useDynamic`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L395,C3) is `false` then integral keys will not be treated any differently than other keys. +// > +// > Lua values are mapped to Pkl values as follows: +// > +// > **Lua type** | **Pkl type** +// > -------------|------------- +// > nil | [`Null`](pkl-lsp://stdlib/base.pkl#L59,C16) +// > boolean | [`Boolean`](pkl-lsp://stdlib/base.pkl#L1058,C16) +// > number | [`Number`](pkl-lsp://stdlib/base.pkl#L585,C25) +// > string | [`String`](pkl-lsp://stdlib/base.pkl#L1094,C16) +// > table | [`Dynamic`](pkl-lsp://stdlib/base.pkl#L1808,C7) or [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7)/[`Listing`](pkl-lsp://stdlib/base.pkl#L1860,C7) depending on [`Parser.useDynamic`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L395,C3) +// > +// > # Example +// > +// > This is a sample Lua file that can be parsed with this Parser. +// > ```lua +// > --[[ +// > This file has a header comment. +// > ]] +// > foo="bar" +// > count=2 +// > -- line comment here +// > enable=true +// > frob=nil +// > ports={80, 443} +// > ips={ +// > localhost = "127.0.0.1"; +// > `"example.com"` = "93.184.215.14"; +// > } +// > _ENV`" "`="space" +// > ``` + /// Determines what the parser produces when parsing Lua. + /// + /// If [true] (the default), the parse result is a [Dynamic], otherwise it's a [Mapping]. + /// + /// For nested tables, if [true] every nested table is a [Dynamic], otherwise a nested table will be a [Mapping] if it + /// contains key/value pairs, a [Listing] if it contains elements, or it will throw an error if it contains both. If + /// [false] then empty tables will be represented as empty [Listing]s. + /// + /// If [useDynamic] is [true], Lua keys named "default" will be shadowed by the built-in [Dynamic.default] property. + useDynamic: Boolean = true +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#useDynamic. +// documentation +// > Determines what the parser produces when parsing Lua. +// > +// > If `true` (the default), the parse result is a [`Dynamic`](pkl-lsp://stdlib/base.pkl#L1808,C7), otherwise it's a [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7). +// > +// > For nested tables, if `true` every nested table is a [`Dynamic`](pkl-lsp://stdlib/base.pkl#L1808,C7), otherwise a nested table will be a [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7) if it +// > contains key/value pairs, a [`Listing`](pkl-lsp://stdlib/base.pkl#L1860,C7) if it contains elements, or it will throw an error if it contains both. If +// > `false` then empty tables will be represented as empty [`Listing`](pkl-lsp://stdlib/base.pkl#L1860,C7)s. +// > +// > If [`useDynamic`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L395,C3) is `true`, Lua keys named "default" will be shadowed by the built-in [`Dynamic.default`](pkl-lsp://stdlib/base.pkl#L1810,C3) property. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Value converters to apply to parsed values. + /// + /// For further information see [ValueRenderer.converters]. Table entries with string keys are treated as properties. + /// This means paths like `x[foo]` will never match anything. + converters: Mapping<(Class|String), (unknown) -> Any> +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#converters. +// documentation +// > Value converters to apply to parsed values. +// > +// > For further information see [`ValueRenderer.converters`](pkl-lsp://stdlib/base.pkl#L308,C3). Table entries with string keys are treated as properties. +// > This means paths like `x`foo`` will never match anything. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + // region Parsing functions + + /// Parses [source] as a strict subset of Lua. + /// + /// Throws if an error occurs during parsing. + /// + /// If [source] is a [Resource], the resource URI is included in parse error messages. + /// + /// In the absence of converters this will return a [Dynamic] or a [Mapping][Mapping]. + function parse(source: Resource|String): unknown = +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// documentation +// > Parses [`source`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L412,C18) as a strict subset of Lua. +// > +// > Throws if an error occurs during parsing. +// > +// > If [`source`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.lua/lua.pkl#L412,C18) is a [`Resource`](pkl-lsp://stdlib/base.pkl#L519,C7), the resource URI is included in parse error messages. +// > +// > In the absence of converters this will return a [`Dynamic`](pkl-lsp://stdlib/base.pkl#L1808,C7) or a [`Mapping`](pkl-lsp://stdlib/base.pkl#L2038,C7). +// ^^^^^^ definition local source_412 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (uri = if (source is Resource) source.uri else null) +// ^^^ definition local uri_413 +// ^^^^^^ reference local source_412 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource# +// ^^^^^^ reference local source_412 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource#uri. + let (source = if (source is Resource) source.text else source) +// ^^^^^^ definition local source_414 +// ^^^^^^ reference local source_412 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource# +// ^^^^^^ reference local source_412 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource#text. +// ^^^^^^ reference local source_412 + let (source = source.replaceAll(Regex(#"\r\n?|\n\r"#), "\n")) // normalize line endings +// ^^^^^^ definition local source_415 +// ^^^^^^ reference local source_414 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + let (tokens = tokenRegex.findMatchesIn(source)) +// ^^^^^^ definition local tokens_416 +// ^^^^^^^^^^ reference local tokenRegex_744 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex#findMatchesIn(). +// ^^^^^^ reference local source_415 + let (state: ParseState = tokens.fold(new ParseState { path = List("^") }, (state: ParseState, token) -> +// ^^^^^ definition local state_417 +// ^^^^^^^^^^ reference local ParseState_642 +// ^^^^^^ reference local tokens_416 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^^^^^^^^ reference local ParseState_642 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#path. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^ definition local state_417 +// ^^^^^^^^^^ reference local ParseState_642 +// ^^^^^ definition local token_417 + // the way parsing works is by folding over a list of tokens and maintaining state in the ParseState object. + // since we don't have enums with associated values, we instead rely on knowing which combinations of state fields + // are reachable and which combinations will never occur. This is a complete list of all valid combinations, where + // the `type` column is "root" for ParseState and "child" for ChildParseState and the other columns are fields: + // + // # | type | op | key | negate | valid next token + // ---|-------|---------|--------|--------|----------------- + // 1a | root | null | null | null | identifier or ";" or EOF + // 1b | child | null | null | null | identifier or value or "[" or "}" or "-" + // 2 | child | null | null | bool | number or "-" + // 3 | root | null | "_ENV" | null | "[" + // 4 | any | null | !null¹ | null | "=" + // 5 | any | "=" | !null | null | value or "-" or "{" + // 6 | any | "=" | !null | bool | number or "-" + // 7 | any | "[" | null | null | value or "-" or "{" + // 8 | any | "[" | null | bool | number or "-" + // 9 | any | "key" | !null | null | "]" + // 10 | any | "]" | !null | null | "=" + // 11 | child | "value" | null | null | "," or ";" or "}" + // + // ¹In state #4, if the type is root then the key cannot be "_ENV" (see state #2). + if (validateToken(token, source, uri).value.startsWith("--")) state // skip comment +// ^^^^^^^^^^^^^ reference local validateToken_781 +// ^^^^^ reference local token_417 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^ reference local state_417 + else if (state.op == null) +// ^^^^^ reference local state_417 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + if (state.key == null) +// ^^^^^ reference local state_417 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. + if (state is ChildParseState) +// ^^^^^ reference local state_417 +// ^^^^^^^^^^^^^^^ reference local ChildParseState_689 + // state #1b/#2, state is ChildParseState + if (state.negate == null && token.value.matches(identifierRegex)) +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^^^^^^^^^^^ reference local identifierRegex_795 + if (token.value is Keyword) throwError("Unexpected keyword `\(token.value)`", source, uri, token) +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Keyword# +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + else (state) { key = token.value; mapStart = super.mapStart ?? token } // -> #4 +// ^^^^^ reference local state_417 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#key. +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#mapStart. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#mapStart. +// ^^^^^ reference local token_417 + else if (state.negate == null && token.value == "[") +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + (state) { op = "[" } // -> #7 +// ^^^^^ reference local state_417 +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#op. + else if (state.negate == null && token.value == "}") +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + let (value = state.toValue(useDynamic, source, uri)) +// ^^^^^ definition local value_450 +// ^^^^^ reference local state_417 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#toValue(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#useDynamic. +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 + let (parent = state.parent) +// ^^^^^^ definition local parent_451 +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#parent. + if (parent.op == "[") // parent is in state #7 +// ^^^^^^ reference local parent_451 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + parent.setKey(convertKey(value, state), state.brace) // -> #9 +// ^^^^^^ reference local parent_451 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#setKey(). +// ^^^^^^^^^^ reference local convertKey_622 +// ^^^^^ reference local value_450 +// ^^^^^ reference local state_417 +// ^^^^^ reference local state_417 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#brace. + else + parent.put(convert(value, parent.path.add(Prop(parent.key!!))), state.brace, useDynamic) // -> #11 or #1a +// ^^^^^^ reference local parent_451 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#put(). +// ^^^^^^^ reference local convert_616 +// ^^^^^ reference local value_450 +// ^^^^^^ reference local parent_451 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#path. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^ reference local Prop_44 +// ^^^^^^ reference local parent_451 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. +// ^^^^^ reference local state_417 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#brace. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#useDynamic. + else if (token.value == "-") +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + state.negate() // -> #2 +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate(). + else + let (value = parseValue(source, uri, state, token, "identifier or value or [ or }")) +// ^^^^^ definition local value_459 +// ^^^^^^^^^^ reference local parseValue_534 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local state_417 +// ^^^^^ reference local token_417 + state.add(convert(value, state.path.add(splatKey)), token) // -> #11 +// ^^^^^ reference local state_417 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#add(). +// ^^^^^^^ reference local convert_616 +// ^^^^^ reference local value_459 +// ^^^^^ reference local state_417 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#path. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^^^^ reference local splatKey_61 +// ^^^^^ reference local token_417 + else + // state #1a, state is ParseState + if (token.value.matches(identifierRegex)) +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^^^^^^^^^^^ reference local identifierRegex_795 + if (token.value is Keyword) throwError("Unexpected keyword `\(token.value)`", source, uri, token) +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Keyword# +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + else (state) { key = token.value } // -> #4 +// ^^^^^ reference local state_417 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#key. +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + else if (token.value == ";") +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + state // stay in state #1a +// ^^^^^ reference local state_417 + else throwExpected("identifier or ;", source, uri, token) +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + else if (state.key == "_ENV" && !(state is ChildParseState)) +// ^^^^^ reference local state_417 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. +// ^^^^^ reference local state_417 +// ^^^^^^^^^^^^^^^ reference local ChildParseState_689 + // state #2, state is ParseState + if (token.value == "[") +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + (state) { key = null; op = "[" } // -> #7 +// ^^^^^ reference local state_417 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#key. +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#op. + else if (token.value == "=") throwError("_ENV cannot be assigned to directly", source, uri, token) +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + else throwExpected("[", source, uri, token) +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + else if (token.value == "=") // key is !null +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + // state #4 + (state) { op = "=" } // -> #5 +// ^^^^^ reference local state_417 +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#op. + else throwExpected("=", source, uri, token) +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + else if (state.op == "=") +// ^^^^^ reference local state_417 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + // state #5/#6 + if (token.value == "-") +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + state.negate() // -> #6 +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate(). + else if (token.value == "{" && state.negate == null) +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. + new ChildParseState { parent = state; brace = token; path = state.path.add(Prop(state.key!!)) } // -> #1b +// ^^^^^^^^^^^^^^^ reference local ChildParseState_689 +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parent. +// ^^^^^ reference local state_417 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#brace. +// ^^^^^ reference local token_417 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#path. +// ^^^^^ reference local state_417 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#path. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^ reference local Prop_44 +// ^^^^^ reference local state_417 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. + else + let (value = parseValue(source, uri, state, token, "value or {")) +// ^^^^^ definition local value_486 +// ^^^^^^^^^^ reference local parseValue_534 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local state_417 +// ^^^^^ reference local token_417 + state.put(convert(value, state.path.add(Prop(state.key!!))), token, useDynamic) // -> #11 or #1a +// ^^^^^ reference local state_417 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#put(). +// ^^^^^^^ reference local convert_616 +// ^^^^^ reference local value_486 +// ^^^^^ reference local state_417 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#path. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^ reference local Prop_44 +// ^^^^^ reference local state_417 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. +// ^^^^^ reference local token_417 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#useDynamic. + else if (state.op == "[") +// ^^^^^ reference local state_417 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + // state #7/#8 + if (token.value == "-") state.negate() // -> #8 +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate(). + else if (token.value == "{" && state.negate == null) +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. + new ChildParseState { parent = state; brace = token; path = List() } // -> #1b +// ^^^^^^^^^^^^^^^ reference local ChildParseState_689 +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parent. +// ^^^^^ reference local state_417 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#brace. +// ^^^^^ reference local token_417 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#path. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + else + let (value = parseValue(source, uri, state, token, "value or {")) +// ^^^^^ definition local value_494 +// ^^^^^^^^^^ reference local parseValue_534 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local state_417 +// ^^^^^ reference local token_417 + if (value == null) throwError("Table key cannot be nil", source, uri, token) +// ^^^^^ reference local value_494 +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + else if (value is Number && value.isNaN) throwError("Table key cannot be NaN", source, uri, token) +// ^^^^^ reference local value_494 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^ reference local value_494 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#isNaN. +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + else state.setKey(convertKey(value, state), token) // -> #9 +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#setKey(). +// ^^^^^^^^^^ reference local convertKey_622 +// ^^^^^ reference local value_494 +// ^^^^^ reference local state_417 +// ^^^^^ reference local token_417 + else if (state.op == "key") +// ^^^^^ reference local state_417 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + // state #9 + if (token.value == "]") (state) { op = "]" } // -> #10 +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^ reference local state_417 +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#op. + else throwExpected("]", source, uri, token) +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + else if (state.op == "]") +// ^^^^^ reference local state_417 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + // state #10 + if (token.value == "=") (state) { op = "=" } // -> #5 +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^ reference local state_417 +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#op. + else throwExpected("=", source, uri, token) +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + else if (state.op == "value" && state is ChildParseState) +// ^^^^^ reference local state_417 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. +// ^^^^^ reference local state_417 +// ^^^^^^^^^^^^^^^ reference local ChildParseState_689 + // state #11, state is ChildParseState + if (token.value is ","|";") (state) { op = null } // -> #1b +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^ reference local state_417 +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#op. + else if (token.value == "}") +// ^^^^^ reference local token_417 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + let (value = state.toValue(useDynamic, source, uri)) +// ^^^^^ definition local value_510 +// ^^^^^ reference local state_417 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#toValue(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#useDynamic. +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 + let (parent = state.parent) +// ^^^^^^ definition local parent_511 +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#parent. + if (parent.op == "[") // parent is in state #7 +// ^^^^^^ reference local parent_511 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + parent.setKey(convertKey(value, parent), state.brace) // -> #9 +// ^^^^^^ reference local parent_511 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#setKey(). +// ^^^^^^^^^^ reference local convertKey_622 +// ^^^^^ reference local value_510 +// ^^^^^^ reference local parent_511 +// ^^^^^ reference local state_417 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#brace. + else + parent.put(convert(value, parent.path.add(Prop(parent.key!!))), state.brace, useDynamic) // -> #11 or #1a +// ^^^^^^ reference local parent_511 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#put(). +// ^^^^^^^ reference local convert_616 +// ^^^^^ reference local value_510 +// ^^^^^^ reference local parent_511 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#path. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^ reference local Prop_44 +// ^^^^^^ reference local parent_511 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. +// ^^^^^ reference local state_417 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#brace. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#useDynamic. + else throwExpected(", or ; or }", source, uri, token) +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + else + // invalid state, we can't ever get here + throwError("Internal error; invalid state", source, uri, token) +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local token_417 + )) + // We're at EOF, check if we allow EOF here + if (state.negate != null) throwExpected("number", source, uri, null) // state #2/#6/#8 +// ^^^^^ reference local state_417 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 + else if (state.op == null) +// ^^^^^ reference local state_417 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + if (state.key == null) +// ^^^^^ reference local state_417 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. + if (state is ChildParseState) throwExpected("identifier or value or [ or }", source, uri, null) // state #1b +// ^^^^^ reference local state_417 +// ^^^^^^^^^^^^^^^ reference local ChildParseState_689 +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 + else convert(state.toValue(useDynamic, source, uri), state.path) // state #1a +// ^^^^^^^ reference local convert_616 +// ^^^^^ reference local state_417 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#toValue(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#useDynamic. +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 +// ^^^^^ reference local state_417 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#path. + else if (state.key == "_ENV" && !(state is ChildParseState)) throwExpected("[", source, uri, null) // state #3 +// ^^^^^ reference local state_417 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. +// ^^^^^ reference local state_417 +// ^^^^^^^^^^^^^^^ reference local ChildParseState_689 +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 + else throwExpected("=", source, uri, null) // state #4 +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 + else if (state.op is "="|"[") throwExpected("value or {", source, uri, null) // state #5/#7 +// ^^^^^ reference local state_417 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 + else if (state.op == "key") throwExpected("]", source, uri, null) // state #9 +// ^^^^^ reference local state_417 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 + else if (state.op == "]") throwExpected("=", source, uri, null) // state #10 +// ^^^^^ reference local state_417 +// ^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 + else /* op is "value" */ throwExpected(", or ; or }", source, uri, null) // state #11 +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_415 +// ^^^ reference local uri_413 + + local function parseValue(source: String, uri: Uri?, state: ParseState, token: RegexMatch, expected: String): (Boolean|Number|String)? = +// ^^^^^^^^^^ definition local parseValue_534 +// ^^^^^^ definition local source_534 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local uri_534 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# +// ^^^^^ definition local state_534 +// ^^^^^^^^^^ reference local ParseState_642 +// ^^^^^ definition local token_534 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^^^^ definition local expected_534 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (value = if (token.value == "nil") null +// ^^^^^ definition local value_535 +// ^^^^^ reference local token_534 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + else if (token.value == "true") true +// ^^^^^ reference local token_534 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + else if (token.value == "false") false +// ^^^^^ reference local token_534 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + else if (token.value.startsWith(Regex(#"\.?0[xX]"#))) +// ^^^^^ reference local token_534 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + parseHexLiteral(token, state.negate ?? false, source, uri) +// ^^^^^^^^^^^^^^^ reference local parseHexLiteral_551 +// ^^^^^ reference local token_534 +// ^^^^^ reference local state_534 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. +// ^^^^^^ reference local source_534 +// ^^^ reference local uri_534 + else if (token.value.startsWith(Regex(#"\.?[0-9]"#))) +// ^^^^^ reference local token_534 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + parseDecLiteral(token, state.negate ?? false, source, uri) +// ^^^^^^^^^^^^^^^ reference local parseDecLiteral_565 +// ^^^^^ reference local token_534 +// ^^^^^ reference local state_534 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. +// ^^^^^^ reference local source_534 +// ^^^ reference local uri_534 + else if (token.value.startsWith(Regex(#"["']"#))) +// ^^^^^ reference local token_534 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + parseShortString(token, source, uri) +// ^^^^^^^^^^^^^^^^ reference local parseShortString_570 +// ^^^^^ reference local token_534 +// ^^^^^^ reference local source_534 +// ^^^ reference local uri_534 + else if (token.value.startsWith(Regex(#"\[=*+\["#))) +// ^^^^^ reference local token_534 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + parseLongString(token) +// ^^^^^^^^^^^^^^^ reference local parseLongString_602 +// ^^^^^ reference local token_534 + else throwExpected(if (state.negate == null) expected else "number", source, uri, token)) +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^ reference local state_534 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. +// ^^^^^^^^ reference local expected_534 +// ^^^^^^ reference local source_534 +// ^^^ reference local uri_534 +// ^^^^^ reference local token_534 + if (state.negate != null && !(value is Number)) +// ^^^^^ reference local state_534 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. +// ^^^^^ reference local value_535 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + throwError("Attempted to negate non-numeric value", source, uri, token) +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^^ reference local source_534 +// ^^^ reference local uri_534 +// ^^^^^ reference local token_534 + else value +// ^^^^^ reference local value_535 + + local function parseHexLiteral(token: RegexMatch, negate: Boolean, source: String, uri: Uri?): Number = +// ^^^^^^^^^^^^^^^ definition local parseHexLiteral_551 +// ^^^^^ definition local token_551 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^^ definition local negate_551 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ definition local source_551 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local uri_551 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + let (match = hexLiteralRegex.matchEntire(token.value) ?? throwError("Invalid numeric literal: \(token.value)", source, uri, token)) +// ^^^^^ definition local match_552 +// ^^^^^^^^^^^^^^^ reference local hexLiteralRegex_793 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex#matchEntire(). +// ^^^^^ reference local token_551 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^ reference local token_551 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_551 +// ^^^ reference local uri_551 +// ^^^^^ reference local token_551 + let (intPart = match.groups[1]!!.value) +// ^^^^^^^ definition local intPart_553 +// ^^^^^ reference local match_552 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + let (fracPart = match.groups[2]?.value ?? "") +// ^^^^^^^^ definition local fracPart_554 +// ^^^^^ reference local match_552 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + let (exp = match.groups[3]?.value?.toInt()) +// ^^^ definition local exp_555 +// ^^^^^ reference local match_552 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + let (base = if (exp != null || !fracPart.isEmpty) 0.0 else 0) +// ^^^^ definition local base_556 +// ^^^ reference local exp_555 +// ^^^^^^^^ reference local fracPart_554 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. + let (intValue: Number = +// ^^^^^^^^ definition local intValue_557 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + if (negate) intPart.chars.fold(base, (acc: Number, it) -> acc * 16 - parseHex(it)) +// ^^^^^^ reference local negate_551 +// ^^^^^^^ reference local intPart_553 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#chars. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^^ reference local base_556 +// ^^^ definition local acc_558 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^ definition local it_558 +// ^^^ reference local acc_558 +// ^^^^^^^^ reference local parseHex_858 +// ^^ reference local it_558 + else intPart.chars.fold(base, (acc: Number, it) -> acc * 16 + parseHex(it))) +// ^^^^^^^ reference local intPart_553 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#chars. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^^ reference local base_556 +// ^^^ definition local acc_559 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^ definition local it_559 +// ^^^ reference local acc_559 +// ^^^^^^^^ reference local parseHex_858 +// ^^ reference local it_559 + let (fracValue = fracPart.chars.foldBack(0.0, (it, acc: Float) -> acc / 16 + parseHex(it) / 16) as Float) +// ^^^^^^^^^ definition local fracValue_560 +// ^^^^^^^^ reference local fracPart_554 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#chars. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#foldBack(). +// ^^ definition local it_560 +// ^^^ definition local acc_560 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# +// ^^^ reference local acc_560 +// ^^^^^^^^ reference local parseHex_858 +// ^^ reference local it_560 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + let (value = if (fracPart.isEmpty) intValue else if (negate) intValue - fracValue else intValue + fracValue) +// ^^^^^ definition local value_561 +// ^^^^^^^^ reference local fracPart_554 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. +// ^^^^^^^^ reference local intValue_557 +// ^^^^^^ reference local negate_551 +// ^^^^^^^^ reference local intValue_557 +// ^^^^^^^^^ reference local fracValue_560 +// ^^^^^^^^ reference local intValue_557 +// ^^^^^^^^^ reference local fracValue_560 + if (exp != null) value * (2.0 ** exp) +// ^^^ reference local exp_555 +// ^^^^^ reference local value_561 +// ^^^ reference local exp_555 + else value +// ^^^^^ reference local value_561 + + local function parseDecLiteral(token: RegexMatch, negate: Boolean, source: String, uri: Uri?): Number = +// ^^^^^^^^^^^^^^^ definition local parseDecLiteral_565 +// ^^^^^ definition local token_565 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^^ definition local negate_565 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ definition local source_565 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local uri_565 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# + let (value = if (negate) "-\(token.value)" else token.value) +// ^^^^^ definition local value_566 +// ^^^^^^ reference local negate_565 +// ^^^^^ reference local token_565 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^ reference local token_565 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + (if (value.contains(Regex("[.eE]"))) value.toFloatOrNull() else value.toIntOrNull()) +// ^^^^^ reference local value_566 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^ reference local value_566 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toFloatOrNull(). +// ^^^^^ reference local value_566 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toIntOrNull(). + ?? throwError("Invalid numeric literal: \(token.value)", source, uri, token) +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^ reference local token_565 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_565 +// ^^^ reference local uri_565 +// ^^^^^ reference local token_565 + + local function parseShortString(token: RegexMatch, source: String, uri: Uri?): String = +// ^^^^^^^^^^^^^^^^ definition local parseShortString_570 +// ^^^^^ definition local token_570 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^^ definition local source_570 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local uri_570 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (value = token.value.substring(1, token.value.length-1)) // drop quotes +// ^^^^^ definition local value_571 +// ^^^^^ reference local token_570 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^^^^ reference local token_570 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + value.replaceAllMapped(Regex(#"(?s-U)\\(z[ \f\n\t\x0b]*|x\p{XDigit}{1,2}|\d{1,3}+|u\{\p{XDigit}*}?|.)"#), (it) -> +// ^^^^^ reference local value_571 +// ^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAllMapped(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^ definition local it_572 + let (value = it.groups[1]!!.value) +// ^^^^^ definition local value_573 +// ^^ reference local it_572 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + if (value.startsWith("z")) "" +// ^^^^^ reference local value_573 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + else if (value == "\n") "\n" +// ^^^^^ reference local value_573 + else if (value == "a") "\u{7}" +// ^^^^^ reference local value_573 + else if (value == "b") "\u{8}" +// ^^^^^ reference local value_573 + else if (value == "f") "\u{c}" +// ^^^^^ reference local value_573 + else if (value == "n") "\n" +// ^^^^^ reference local value_573 + else if (value == "r") "\r" +// ^^^^^ reference local value_573 + else if (value == "t") "\t" +// ^^^^^ reference local value_573 + else if (value == "v") "\u{b}" +// ^^^^^ reference local value_573 + else if (value is "\\"|"\""|"'") value +// ^^^^^ reference local value_573 +// ^^^^^ reference local value_573 + else if (value.startsWith("x")) +// ^^^^^ reference local value_573 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + if (!value.matches(Regex(#"(?-U)x\p{XDigit}{2}"#))) throwError("Invalid hex escape in string: \(it.value)", source, uri, it) +// ^^^^^ reference local value_573 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^^ reference local throwError_826 +// ^^ reference local it_572 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_570 +// ^^^ reference local uri_570 +// ^^ reference local it_572 + else + let (c = parseHexOctet(value.drop(1))) +// ^ definition local c_587 +// ^^^^^^^^^^^^^ reference local parseHexOctet_861 +// ^^^^^ reference local value_573 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). + if (c > 0x7f) throwError("Non-ascii hex escape in string: \(it.value)", source, uri, it) +// ^ reference local c_587 +// ^^^^^^^^^^ reference local throwError_826 +// ^^ reference local it_572 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_570 +// ^^^ reference local uri_570 +// ^^ reference local it_572 + else c.toChar() +// ^ reference local c_587 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toChar(). + else if (value.startsWith("u")) +// ^^^^^ reference local value_573 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + if (!value.matches(Regex(#"(?-U)u\{\p{XDigit}{1,8}}"#))) throwError("Invalid unicode escape in string: \(it.value)", source, uri, it) +// ^^^^^ reference local value_573 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^^^^^^^^^ reference local throwError_826 +// ^^ reference local it_572 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_570 +// ^^^ reference local uri_570 +// ^^ reference local it_572 + else + let (c = parseHex32(value.substring(2, value.length-1).padStart(8, "0"))) +// ^ definition local c_593 +// ^^^^^^^^^^ reference local parseHex32_864 +// ^^^^^ reference local value_573 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^^^^ reference local value_573 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). + if (c > 0x10FFFF) throwError("Out-of-range unicode escape in string: \(it.value)", source, uri, it) +// ^ reference local c_593 +// ^^^^^^^^^^ reference local throwError_826 +// ^^ reference local it_572 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_570 +// ^^^ reference local uri_570 +// ^^ reference local it_572 + else c.toChar() +// ^ reference local c_593 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toChar(). + else if (value.matches(Regex(#"[0-9]{1,3}"#))) +// ^^^^^ reference local value_573 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + let (c = value.toInt()) +// ^ definition local c_597 +// ^^^^^ reference local value_573 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toInt(). + if (c > 0x7f) throwError("Non-ascii decimal escape in string: \(it.value)", source, uri, it) +// ^ reference local c_597 +// ^^^^^^^^^^ reference local throwError_826 +// ^^ reference local it_572 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_570 +// ^^^ reference local uri_570 +// ^^ reference local it_572 + else c.toChar() +// ^ reference local c_597 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toChar(). + else throwError("Invalid backslash in string: \(it.value)", source, uri, it)) +// ^^^^^^^^^^ reference local throwError_826 +// ^^ reference local it_572 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_570 +// ^^^ reference local uri_570 +// ^^ reference local it_572 + + local function parseLongString(token: RegexMatch): String = +// ^^^^^^^^^^^^^^^ definition local parseLongString_602 +// ^^^^^ definition local token_602 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + // we know we start with [=…[ and end with ]=…] (end was validated in validateToken) + // group 5 is starting equals, group 6 is the whole end + let (value = token.value.substring(token.groups[5]!!.end-token.start+1, token.groups[6]!!.start-token.start)) +// ^^^^^ definition local value_605 +// ^^^^^ reference local token_602 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^^^^ reference local token_602 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#end. +// ^^^^^ reference local token_602 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. +// ^^^^^ reference local token_602 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. +// ^^^^^ reference local token_602 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. + if (value.startsWith("\n")) value.drop(1) +// ^^^^^ reference local value_605 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). +// ^^^^^ reference local value_605 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). + else value +// ^^^^^ reference local value_605 + + // endregion + // region Converters + + // path specs are already in reversed order + local pathConverters: List, (unknown) -> Any>> = +// ^^^^^^^^^^^^^^ definition local pathConverters_613 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + splitPathConverters(converters.toMap()) +// ^^^^^^^^^^^^^^^^^^^ reference local splitPathConverters_63 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#converters. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + + local function convert(value: Value, path: List): unknown = +// ^^^^^^^ definition local convert_616 +// ^^^^^ definition local value_616 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Value# +// ^^^^ definition local path_616 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# + let (path = path.reverse()) +// ^^^^ definition local path_617 +// ^^^^ reference local path_616 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#reverse(). + let (f = pathConverters.findOrNull((p) -> comparePaths(path, p.key))?.value) +// ^ definition local f_618 +// ^^^^^^^^^^^^^^ reference local pathConverters_613 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#findOrNull(). +// ^ definition local p_618 +// ^^^^^^^^^^^^ reference local comparePaths_630 +// ^^^^ reference local path_617 +// ^ reference local p_618 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#key. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#value. + let (f = f ?? converters.getOrNull(value.getClass())) +// ^ definition local f_619 +// ^ reference local f_618 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#converters. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^ reference local value_616 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + if (f != null) f.apply(value) else value +// ^ reference local f_619 +// ^ reference local f_619 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^ reference local value_616 +// ^^^^^ reference local value_616 + + local function convertKey(value: Value, state: ParseState): unknown = +// ^^^^^^^^^^ definition local convertKey_622 +// ^^^^^ definition local value_622 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Value# +// ^^^^^ definition local state_622 +// ^^^^^^^^^^ reference local ParseState_642 + if (state.isListIndex(value) && (useDynamic || state is ChildParseState)) value // don't convert indices +// ^^^^^ reference local state_622 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#isListIndex(). +// ^^^^^ reference local value_622 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#useDynamic. +// ^^^^^ reference local state_622 +// ^^^^^^^^^^^^^^^ reference local ChildParseState_689 +// ^^^^^ reference local value_622 + else if (value is String) value // String keys are treated as properties +// ^^^^^ reference local value_622 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference local value_622 + else + let (f = converters.getOrNull(value.getClass())) +// ^ definition local f_626 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#converters. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^ reference local value_622 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + if (f != null) f.apply(value) else value +// ^ reference local f_626 +// ^ reference local f_626 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^ reference local value_622 +// ^^^^^ reference local value_622 + + // the path and spec must already be reversed + local function comparePaths(path: List, pathSpec: List): Boolean = +// ^^^^^^^^^^^^ definition local comparePaths_630 +// ^^^^ definition local path_630 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^^^^^^ definition local pathSpec_630 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + path.length >= pathSpec.length && path.zip(pathSpec).every((p) -> +// ^^^^ reference local path_630 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^^^^^ reference local pathSpec_630 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. +// ^^^^ reference local path_630 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#zip(). +// ^^^^^^^^ reference local pathSpec_630 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^ definition local p_631 + if (p.second is Prop && p.second.name == "*") p.first is Prop +// ^ reference local p_631 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^^ reference local Prop_47 +// ^ reference local p_631 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Prop#name. +// ^ reference local p_631 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^^^^ reference local Prop_47 + else if (p.second is Key && p.second.key == "*") p.first is Key +// ^ reference local p_631 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^ reference local Key_55 +// ^ reference local p_631 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Key#key. +// ^ reference local p_631 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^^^ reference local Key_55 + else p.first == p.second +// ^ reference local p_631 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. +// ^ reference local p_631 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. + ) + + // endregion + } + + // region State + + local open class ParseState { +// ^^^^^^^^^^ definition local ParseState_642 + map: Map // note: can't provide key/value types, converters can return non-Lua types +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#map. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# + list: List +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#list. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# + key: Any = null +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + op: ("["|"key"|"]"|"=")? // op is "["? iff key is null +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + negate: Boolean? // negative numbers are unary negation +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + path: List +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#path. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/PathEntry# + + function toValue(useDynamic: Boolean, _, _): Dynamic|Mapping = +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#toValue(). +// ^^^^^^^^^^ definition local useDynamic_650 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + if (useDynamic) (map.toDynamic()) { +// ^^^^^^^^^^ reference local useDynamic_650 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#map. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toDynamic(). + ...list +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#list. + } else map.toMapping() // list should be empty +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#map. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMapping(). + + function put(value, token, useDynamic: Boolean): ParseState = +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#put(). +// ^^^^^ definition local value_655 +// ^^^^^ definition local token_655 +// ^^^^^^^^^^ definition local useDynamic_655 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^^^^ reference local ParseState_642 + if (useDynamic && isListIndex(key)) add(value, token) +// ^^^^^^^^^^ reference local useDynamic_655 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#isListIndex(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#add(). +// ^^^^^ reference local value_655 +// ^^^^^ reference local token_655 + else (this) { + map = super.map.put(super.key!!, value) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#map. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#map. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#put(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. +// ^^^^^ reference local value_655 + key = null +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. + op = null +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + negate = null +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. + } + + // used for _ENV[0]=value expressions when useDynamic is true + function add(value, _): ParseState = +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#add(). +// ^^^^^ definition local value_665 +// ^^^^^^^^^^ reference local ParseState_642 + (this) { + list = super.list.add(value) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#list. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#list. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^ reference local value_665 + key = null +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. + op = null +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + negate = null +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. + } + + // only use this for [key]= keys + function setKey(value, _): ParseState = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#setKey(). +// ^^^^^ definition local value_674 +// ^^^^^^^^^^ reference local ParseState_642 + (this) { + key = value +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. +// ^^^^^ reference local value_674 + op = "key" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#op. + negate = null +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. + } + + function negate(): ParseState = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate(). +// ^^^^^^^^^^ reference local ParseState_642 + (this) { negate = !(super.negate ?? false) } +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#negate. + + function isListIndex(key): Boolean = +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#isListIndex(). +// ^^^ definition local key_684 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + // note: Lua indexes are 1-based + key is Int && key == list.length + 1 +// ^^^ reference local key_684 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^ reference local key_684 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#list. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. + } + + local class ChildParseState extends ParseState { +// ^^^^^^^^^^^^^^^ definition local ChildParseState_689 +// ^^^^^^^^^^ reference local ParseState_642 + parent: ParseState +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#parent. +// ^^^^^^^^^^ reference local ParseState_642 + brace: RegexMatch // token for opening {, used for error reporting +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#brace. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# + op: ("["|"key"|"]"|"="|"value")? // op is "["|"value"? iff key is null +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#op. + mapStart: RegexMatch? // non-null if !map.isEmpty +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#mapStart. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# + listStart: RegexMatch? // non-null if !list.isEmpty +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#listStart. +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# + + function toValue(useDynamic: Boolean, source: String, uri: Uri?): Dynamic|Mapping|Listing = +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#toValue(). +// ^^^^^^^^^^ definition local useDynamic_696 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^ definition local source_696 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local uri_696 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + if (useDynamic) (map.toDynamic()) { +// ^^^^^^^^^^ reference local useDynamic_696 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#map. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toDynamic(). + ...list + } else if (map.isEmpty) list.toListing() +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#map. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#isEmpty. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#list. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toListing(). + else if (list.isEmpty) map.toMapping() +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#list. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#map. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMapping(). + else throwError2("Table has both list elements and map entries", source, uri, mapStart!!, "first map entry", listStart!!, "first list entry") +// ^^^^^^^^^^^ reference local throwError2_831 +// ^^^^^^ reference local source_696 +// ^^^ reference local uri_696 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#mapStart. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#listStart. + + function put(value, token: RegexMatch, _): ChildParseState = +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#put(). +// ^^^^^ definition local value_703 +// ^^^^^ definition local token_703 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^^^^^^^^^^^ reference local ChildParseState_689 + if (isListIndex(key)) add(value, token) +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#isListIndex(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#add(). +// ^^^^^ reference local value_703 +// ^^^^^ reference local token_703 + else (this) { + map = super.map.put(super.key!!, value) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#map. +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#map. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#put(). +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#key. +// ^^^^^ reference local value_703 + key = null +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#key. + op = "value" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#op. + negate = null +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#negate. + } + + function add(value, token: RegexMatch): ChildParseState = +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#add(). +// ^^^^^ definition local value_712 +// ^^^^^ definition local token_712 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^^^^^^^^^^^ reference local ChildParseState_689 + (this) { + list = super.list.add(value) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#list. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#list. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^^^^^ reference local value_712 + key = null // key could be [int] +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#key. + op = "value" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#op. + negate = null +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#negate. + listStart = super.listStart ?? token +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#listStart. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#listStart. +// ^^^^^ reference local token_712 + } + + function setKey(value, token: RegexMatch): ChildParseState = +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#setKey(). +// ^^^^^ definition local value_721 +// ^^^^^ definition local token_721 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^^^^^^^^^^^ reference local ChildParseState_689 + (this) { + key = value +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#key. +// ^^^^^ reference local value_721 + op = "key" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#op. + negate = null +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#negate. + mapStart = +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#mapStart. + // don't update mapStart if this will become a listing element + if (isListIndex(value)) super.mapStart +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ParseState#isListIndex(). +// ^^^^^ reference local value_721 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#mapStart. + else super.mapStart ?? token +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ChildParseState#mapStart. +// ^^^^^ reference local token_721 + } + } + + // endregion + // region Tokens + + // Regex that matches a single Lua token, or an invalid character. + // This regex assumes line endings have already been normalized, so no carriage returns exist. + // Error states: + // - Group 2 is "" + // - Group 3 is not "\""? + // - Group 4 is not "'"? + // - Group 6 is "" + // - Last group is non-null + local const tokenRegex: Regex = Regex(##""" +// ^^^^^^^^^^ definition local tokenRegex_744 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + (?x-uU) + --(?: # comment + \[(?=*)\[ # long comment (equals are GROUP 1) + (?>(?> + [^]] + | ](?!\k]) + )*) + (]\k]|\z) # match end or EOF (GROUP 2) + | .* # short comment + ) + | [\w&&\D]\w* # identifier + | "(?>(?> # short literal string (") + [^\\\n"] + | \\(?>z[\ \f\n\t\x0b]*|x\p{XDigit}{2}|\d{1,3}|u\{\p{XDigit}+}|(?s:.)|\z) + )*)("|(?s:.)|\z) # match string truncated by newline or EOF (GROUP 3) + | '(?>(?> # short literal string (') + [^\\\n'] + | \\(?>z[\ \f\n\t\x0b]*|x\p{XDigit}{2}|\d{1,3}|u\{\p{XDigit}+}|(?s:.)|\z) + )*)('|(?s:.)|\z) # match string truncated by newline or EOF (GROUP 4) + | \[(?=*)\[ # long literal string (equals are GROUP 5) + (?>(?> + [^]] + | ](?!\k]) + )*) + (]\k]|\z) # match end or EOF (GROUP 6) + # for the numeric literals, they consume extra periods and hex digits and throw a parse error + # this regex aims to match everything Lua 5.3 itself will tokenize as numeric + | \.?0[xX](?:(?:[pP][-+]?)?[.\p{XDigit}])* # hex numeric literal + | \.?\d(?:(?:[eE][-+]?)?[.\p{XDigit}])* # dec numeric literal + | [-+*%^\#&|(){}\[\];,] # single-char operators + | <[<=]? | >[>=]? | //? | ~=? | ==? | ::? | \.{1,3} # multi-char operators + | ([^\ \f\n\t\x0b]) # invalid token (last group) + """##) + + // checks the error states documented on tokenRegex + // returns the same token, or throws an error + local const function validateToken(token: RegexMatch, source: String, uri: Uri?): RegexMatch = +// ^^^^^^^^^^^^^ definition local validateToken_781 +// ^^^^^ definition local token_781 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^^ definition local source_781 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local uri_781 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# + if (token.groups[2]?.value == "") throwError("Expected ]\(token.groups[1]!!.value)], found EOF", source, uri, token.groups[2]!!) +// ^^^^^ reference local token_781 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^ reference local token_781 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_781 +// ^^^ reference local uri_781 +// ^^^^^ reference local token_781 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. + else let (g = token.groups[3]) if (g != null && g.value != "\"") throwExpected("\"", source, uri, g) +// ^ definition local g_783 +// ^^^^^ reference local token_781 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^ reference local g_783 +// ^ reference local g_783 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_781 +// ^^^ reference local uri_781 +// ^ reference local g_783 + else let (g = token.groups[4]) if (g != null && g.value != "'") throwExpected("'", source, uri, g) +// ^ definition local g_784 +// ^^^^^ reference local token_781 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^ reference local g_784 +// ^ reference local g_784 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^^^^ reference local throwExpected_846 +// ^^^^^^ reference local source_781 +// ^^^ reference local uri_781 +// ^ reference local g_784 + else if (token.groups[6]?.value == "") throwError("Expected ]\(token.groups[5]!!.value)], found EOF", source, uri, token.groups[6]!!) +// ^^^^^ reference local token_781 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^ reference local token_781 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_781 +// ^^^ reference local uri_781 +// ^^^^^ reference local token_781 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. + else let (g = token.groups.last) if (g != null) throwError("Illegal token \(g.value)", source, uri, g) +// ^ definition local g_786 +// ^^^^^ reference local token_781 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#groups. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. +// ^ reference local g_786 +// ^^^^^^^^^^ reference local throwError_826 +// ^ reference local g_786 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^ reference local source_781 +// ^^^ reference local uri_781 +// ^ reference local g_786 + else token +// ^^^^^ reference local token_781 + + // groups: + // 1 - integral part (String) + // 2 - fractional part (String?) + // 3 - exponent (String(!isEmpty)?) + local const hexLiteralRegex: Regex = Regex(#"(?-U)0[xX](?=\.?\p{XDigit})(\p{XDigit}*)(?:\.(\p{XDigit}*))?(?:[pP]([-+]?\d+))?"#) +// ^^^^^^^^^^^^^^^ definition local hexLiteralRegex_793 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + + local const identifierRegex = Regex("[a-zA-Z_][a-zA-Z0-9_]*") +// ^^^^^^^^^^^^^^^ definition local identifierRegex_795 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + + // endregion + // region Errors + + local class ErrorLocation { +// ^^^^^^^^^^^^^ definition local ErrorLocation_800 + row1: Int // 1-based row +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#row1. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + col1: Int // 1-based column +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#col1. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + line: String // with prefix +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#line. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + marker: String +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#marker. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + local const function errorLocation(source: String, token: RegexMatch): ErrorLocation = +// ^^^^^^^^^^^^^ definition local errorLocation_807 +// ^^^^^^ definition local source_807 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local token_807 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^^^^^^^^^ reference local ErrorLocation_800 + let (lineOffset = (source.take(token.start).lastIndexOfOrNull("\n") ?? -1) + 1) +// ^^^^^^^^^^ definition local lineOffset_808 +// ^^^^^^ reference local source_807 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#take(). +// ^^^^^ reference local token_807 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. +// ^^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#lastIndexOfOrNull(). + // locate the entire line the token starts on + let (lineEndOffset = source.drop(token.start).indexOfOrNull("\n")) +// ^^^^^^^^^^^^^ definition local lineEndOffset_810 +// ^^^^^^ reference local source_807 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^^^^ reference local token_807 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#indexOfOrNull(). + let (source = if (lineEndOffset != null) source.take(token.start + lineEndOffset) else source) +// ^^^^^^ definition local source_811 +// ^^^^^^^^^^^^^ reference local lineEndOffset_810 +// ^^^^^^ reference local source_807 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#take(). +// ^^^^^ reference local token_807 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. +// ^^^^^^^^^^^^^ reference local lineEndOffset_810 +// ^^^^^^ reference local source_807 + // zero-width split so we don't lose any blank lines from the end + let (lines = source.split(Regex(#"(?<=\n)"#))) +// ^^^^^ definition local lines_813 +// ^^^^^^ reference local source_811 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + let (_line = lines.last) +// ^^^^^ definition local _line_814 +// ^^^^^ reference local lines_813 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#last. + let (_row1 = lines.length) +// ^^^^^ definition local _row1_815 +// ^^^^^ reference local lines_813 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#length. + let (col0 = math.min(token.start - lineOffset, _line.length) as Int) // min() is just in case +// ^^^^ definition local col0_816 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^ reference pkl . pkl 0.29.0 `pkl.math`/min(). +// ^^^^^ reference local token_807 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. +// ^^^^^^^^^^ reference local lineOffset_808 +// ^^^^^ reference local _line_814 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + let (rowPrefix = "\(_row1) | ") +// ^^^^^^^^^ definition local rowPrefix_817 +// ^^^^^ reference local _row1_815 + let (markerPrefix = " ".repeat(rowPrefix.length - 3) + " | ") +// ^^^^^^^^^^^^ definition local markerPrefix_818 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^^^^^ reference local rowPrefix_817 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + new ErrorLocation { +// ^^^^^^^^^^^^^ reference local ErrorLocation_800 + row1 = _row1 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/row1. +// ^^^^^ reference local _row1_815 + col1 = col0 + 1 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/col1. +// ^^^^ reference local col0_816 + line = "\(rowPrefix)\(_line)" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/line. +// ^^^^^^^^^ reference local rowPrefix_817 +// ^^^^^ reference local _line_814 + marker = markerPrefix + " ".repeat(col0) + "^".repeat(math.max(1, math.min(_line.length - col0, token.end - token.start)) as UInt) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/marker. +// ^^^^^^^^^^^^ reference local markerPrefix_818 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^ reference local col0_816 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^ reference pkl . pkl 0.29.0 `pkl.math`/max(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^ reference pkl . pkl 0.29.0 `pkl.math`/min(). +// ^^^^^ reference local _line_814 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^ reference local col0_816 +// ^^^^^ reference local token_807 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#end. +// ^^^^^ reference local token_807 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#start. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + } + + local const function throwError(msg: String, source: String, uri: Uri?, token: RegexMatch): nothing = +// ^^^^^^^^^^ definition local throwError_826 +// ^^^ definition local msg_826 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ definition local source_826 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local uri_826 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# +// ^^^^^ definition local token_826 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# + let (loc = errorLocation(source, token)) +// ^^^ definition local loc_827 +// ^^^^^^^^^^^^^ reference local errorLocation_807 +// ^^^^^^ reference local source_826 +// ^^^^^ reference local token_826 + let (errMsg = "\(msg)\n\n\(loc.line)\n\(loc.marker)\nat \(uri ?? ""):\(loc.row1):\(loc.col1)") +// ^^^^^^ definition local errMsg_828 +// ^^^ reference local msg_826 +// ^^^ reference local loc_827 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#line. +// ^^^ reference local loc_827 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#marker. +// ^^^ reference local uri_826 +// ^^^ reference local loc_827 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#row1. +// ^^^ reference local loc_827 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#col1. + throw(errMsg) +// ^^^^^^ reference local errMsg_828 + + local const function throwError2(msg: String, source: String, uri: Uri?, token1: RegexMatch, note1: String, token2: RegexMatch, note2: String): nothing = +// ^^^^^^^^^^^ definition local throwError2_831 +// ^^^ definition local msg_831 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ definition local source_831 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local uri_831 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# +// ^^^^^^ definition local token1_831 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^ definition local note1_831 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ definition local token2_831 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^ definition local note2_831 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (loc1 = errorLocation(source, token1)) +// ^^^^ definition local loc1_832 +// ^^^^^^^^^^^^^ reference local errorLocation_807 +// ^^^^^^ reference local source_831 +// ^^^^^^ reference local token1_831 + let (loc2 = errorLocation(source, token2)) +// ^^^^ definition local loc2_833 +// ^^^^^^^^^^^^^ reference local errorLocation_807 +// ^^^^^^ reference local source_831 +// ^^^^^^ reference local token2_831 + let (errMsg = +// ^^^^^^ definition local errMsg_834 + if (loc1.row1 == loc2.row1) // same line +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#row1. +// ^^^^ reference local loc2_833 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#row1. + if (loc1.col1 <= loc2.col1) // loc1 comes first +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#col1. +// ^^^^ reference local loc2_833 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#col1. + "\(msg)\n\n\(loc1.line)\n\(loc1.marker) \(note1)\n\(loc2.marker) \(note2)\nat \(uri ?? ""):\(loc1.row1):\(loc1.col1)" +// ^^^ reference local msg_831 +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#line. +// ^^^^ reference local loc1_832 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#marker. +// ^^^^^ reference local note1_831 +// ^^^^ reference local loc2_833 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#marker. +// ^^^^^ reference local note2_831 +// ^^^ reference local uri_831 +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#row1. +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#col1. + else // loc2 comes first + "\(msg)\n\n\(loc1.line)\n\(loc2.marker) \(note2)\n\(loc1.marker) \(note1)\nat \(uri ?? ""):\(loc1.row1):\(loc2.col1)" +// ^^^ reference local msg_831 +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#line. +// ^^^^ reference local loc2_833 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#marker. +// ^^^^^ reference local note2_831 +// ^^^^ reference local loc1_832 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#marker. +// ^^^^^ reference local note1_831 +// ^^^ reference local uri_831 +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#row1. +// ^^^^ reference local loc2_833 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#col1. + else if (loc1.row1 < loc2.row1) // loc1 comes first +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#row1. +// ^^^^ reference local loc2_833 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#row1. + "\(msg)\n\n\(loc1.line)\n\(loc1.marker) \(note1)\n\(loc2.line)\n\(loc2.marker) \(note2)\nat \(uri ?? ""):\(loc1.row1):\(loc1.col1)" +// ^^^ reference local msg_831 +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#line. +// ^^^^ reference local loc1_832 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#marker. +// ^^^^^ reference local note1_831 +// ^^^^ reference local loc2_833 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#line. +// ^^^^ reference local loc2_833 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#marker. +// ^^^^^ reference local note2_831 +// ^^^ reference local uri_831 +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#row1. +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#col1. + else // loc2 comes first + "\(msg)\n\n\(loc2.line)\n\(loc2.marker) \(note2)\n\(loc1.line)\n\(loc1.marker) \(note1)\nat \(uri ?? ""):\(loc2.row1):\(loc2.col1)") +// ^^^ reference local msg_831 +// ^^^^ reference local loc2_833 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#line. +// ^^^^ reference local loc2_833 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#marker. +// ^^^^^ reference local note2_831 +// ^^^^ reference local loc1_832 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#line. +// ^^^^ reference local loc1_832 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#marker. +// ^^^^^ reference local note1_831 +// ^^^ reference local uri_831 +// ^^^^ reference local loc2_833 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#row1. +// ^^^^ reference local loc2_833 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/ErrorLocation#col1. + throw(errMsg) +// ^^^^^^ reference local errMsg_834 + + local const function throwExpected(expected: String, source: String, uri: Uri?, token: RegexMatch?): nothing = +// ^^^^^^^^^^^^^ definition local throwExpected_846 +// ^^^^^^^^ definition local expected_846 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ definition local source_846 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ definition local uri_846 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Uri# +// ^^^^^ definition local token_846 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# + let (found = +// ^^^^^ definition local found_847 + if (token == null) "EOF" +// ^^^^^ reference local token_846 + else if (token.value == "\n") "newline" +// ^^^^^ reference local token_846 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + else if (token.value.isEmpty) "EOF" +// ^^^^^ reference local token_846 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. + else "token `\(token.value.replaceAllMapped(Regex(#"[\n\\]"#), (it) -> if (it.value == "\n") "\\n" else #"\\"#))`") +// ^^^^^ reference local token_846 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. +// ^^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAllMapped(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). +// ^^ definition local it_851 +// ^^ reference local it_851 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch#value. + throwError("Expected \(expected), found \(found)", source, uri, token ?? new RegexMatch { value = ""; start = source.length; end = source.length }) +// ^^^^^^^^^^ reference local throwError_826 +// ^^^^^^^^ reference local expected_846 +// ^^^^^ reference local found_847 +// ^^^^^^ reference local source_846 +// ^^^ reference local uri_846 +// ^^^^^ reference local token_846 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RegexMatch# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/value. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/start. +// ^^^^^^ reference local source_846 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/end. +// ^^^^^^ reference local source_846 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + + // endregion + // endregion + // region Hex + + /// parseHex tranforms a single hexadecimal character into its unsigned integer representation. + local const function parseHex(digit: Char): UInt8 = nybbleLut.getOrNull(digit) ?? throw("Unrecognized hex digit: \(digit)") +// ^^^^^^^^ definition local parseHex_858 +// documentation +// > parseHex tranforms a single hexadecimal character into its unsigned integer representation. +// ^^^^^ definition local digit_859 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Char# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# +// ^^^^^^^^^ reference local nybbleLut_871 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^ reference local digit_859 +// ^^^^^ reference local digit_859 + + /// parseHexOctet tranforms a two hexadecimal characters into its unsigned integer representation. + local const function parseHexOctet(octet: String(length == 2)): UInt8 = byteLut.getOrNull(octet) ?? throw("Unrecognized hex octet: \(octet)") +// ^^^^^^^^^^^^^ definition local parseHexOctet_861 +// documentation +// > parseHexOctet tranforms a two hexadecimal characters into its unsigned integer representation. +// ^^^^^ definition local octet_862 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt8# +// ^^^^^^^ reference local byteLut_881 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^ reference local octet_862 +// ^^^^^ reference local octet_862 + + /// parseHex32 transforms an 8 character hexidecimal string into its UInt32 representation. + local const function parseHex32(s: String(length == 8)): UInt32 = +// ^^^^^^^^^^ definition local parseHex32_864 +// documentation +// > parseHex32 transforms an 8 character hexidecimal string into its UInt32 representation. +// ^ definition local s_865 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt32# + IntSeq(0, 7) +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). + .step(2) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq#step(). + .map((it) -> s.substring(it, it + 2)) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq#map(). +// ^^ definition local it_868 +// ^ reference local s_865 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#substring(). +// ^^ reference local it_868 +// ^^ reference local it_868 + .fold(0, (acc, it) -> acc.shl(8) + parseHexOctet(it)) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^ definition local acc_869 +// ^^ definition local it_869 +// ^^^ reference local acc_869 +// ^^^^^^^^^^^^^ reference local parseHexOctet_861 +// ^^ reference local it_869 + + local const nybbleLut = new Mapping { +// ^^^^^^^^^ definition local nybbleLut_871 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + for (n in IntSeq(0, 9)) { +// ^ definition local n_872 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). + [n.toString()] = n +// ^ reference local n_872 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). +// ^ reference local n_872 + } + for (n in IntSeq(0xa, 0xf)) { +// ^ definition local n_875 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/IntSeq(). + [n.toRadixString(16)] = n +// ^ reference local n_875 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). +// ^ reference local n_875 + [n.toRadixString(16).toUpperCase()] = n +// ^ reference local n_875 +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toRadixString(). +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toUpperCase(). +// ^ reference local n_875 + } + } + + local const byteLut = new Mapping { +// ^^^^^^^ definition local byteLut_881 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + for (k,v in nybbleLut) { +// ^ definition local k_882 +// ^ definition local v_882 +// ^^^^^^^^^ reference local nybbleLut_871 + for (k2,v2 in nybbleLut) { +// ^^ definition local k2_883 +// ^^ definition local v2_883 +// ^^^^^^^^^ reference local nybbleLut_871 + ["\(k)\(k2)"] = v.shl(4) + v2 +// ^ reference local k_882 +// ^^ reference local k2_883 +// ^ reference local v_882 +// ^^ reference local v2_883 + } + } + } + + // endregion + + output {} // makes the above endregion comment work +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/output. + diff --git a/pkl-pantrysnapshot/pkl.lua/tests/parser.pkl b/pkl-pantrysnapshot/pkl.lua/tests/parser.pkl new file mode 100755 index 00000000..24e93918 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.lua/tests/parser.pkl @@ -0,0 +1,894 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.lua.tests.parser +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/ + + amends "pkl:test" + + import "../lua.pkl" + import "pkl:math" + + local parser: lua.Parser = new {} +// ^^^^^^ definition local parser_23 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser# + + local function parseValue(s: String): lua.Value = +// ^^^^^^^^^^ definition local parseValue_25 +// ^ definition local s_25 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Value# + let (map = (parser) { useDynamic = false }.parse("value=\(s)")) +// ^^^ definition local map_26 +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/useDynamic. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^ reference local s_25 + if (map.length == 1) map["value"] +// ^^^ reference local map_26 +// ^^^ reference local map_26 + else throw("source parsed as more than one value: \(s)") +// ^ reference local s_25 + + local function parseDynamic(s: String): lua.Value = +// ^^^^^^^^^^^^ definition local parseDynamic_30 +// ^ definition local s_30 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Value# + let (map = parser.parse("value=\(s)").toMap()) +// ^^^ definition local map_31 +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^ reference local s_30 + if (map.length == 1) map["value"] +// ^^^ reference local map_31 +// ^^^ reference local map_31 + else throw("source parsed as more than one value: \(s)") +// ^ reference local s_30 + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/facts. + ["hex floats"] { + // with the way we parse hex floats, check for precision issues + parseValue("0xaBcD") is Int(this == 0xabcd) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + parseValue("0X80.0") is Float(this == 0x80) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + parseValue("0x80.8") is Float(this == 128.5) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + parseValue("0x7f.f0") is Float(this == 127.9375) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + parseValue("0x7f.84") is Float(this == 127.515625) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + parseValue("0x7f.abc") is Float(this == 127.6708984375) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + parseValue("-0x7f.abc") is Float(this == -127.6708984375) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + parseValue("0x1p1") is Float(this == 2.0) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + parseValue("0x1p+1") is Float(this == 2.0) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + parseValue("0x1p2") is Float(this == 4.0) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + parseValue("0x1p-1") is Float(this == 0.5) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + parseValue("0x80.8p1") is Float(this == 257.0) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# + parseValue("0x7fffffffffffffff") is Int(this == math.maxInt) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxInt. + parseValue("-0x8000000000000000") is Int(this == math.minInt) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/minInt. + parseValue("0x1.fffffffffffffp+1023") is Float(this == math.maxFiniteFloat) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxFiniteFloat. + parseValue("-0x1.fffffffffffffp+1023") is Float(this == math.minFiniteFloat) +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Float# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/minFiniteFloat. + } + ["negative numbers"] { + // negative numbers are a unary negation on a positive number + parseValue("-1") == -1 +// ^^^^^^^^^^ reference local parseValue_25 + // we support double-negation because the alternative is giving the user an error like + // error: expected number, found token '-' + // and that's just confusing. + parseValue("- -1") == 1 +// ^^^^^^^^^^ reference local parseValue_25 + parseValue("- - - 1") == -1 +// ^^^^^^^^^^ reference local parseValue_25 + parseValue("-\n1") == -1 +// ^^^^^^^^^^ reference local parseValue_25 + parseValue("\(math.maxUInt)") == math.maxUInt +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxUInt. + parseValue("\(math.maxInt)") == math.maxInt +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxInt. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/maxInt. + parseValue("\(math.minInt)") == math.minInt +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/minInt. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.math`/minInt. + parseValue("-0.1") == -0.1 +// ^^^^^^^^^^ reference local parseValue_25 + parseValue("-0xABC") == -0xABC +// ^^^^^^^^^^ reference local parseValue_25 + parseValue("-2e1") == -2e1 +// ^^^^^^^^^^ reference local parseValue_25 + } + ["tables with useDynamic=true"] { + // note: new Dynamic { 1; 2 } == new Dynamic { [0] = 1; [1] = 2 }, so we have to take care with comparisons + parseDynamic("{}") == new Dynamic {} +// ^^^^^^^^^^^^ reference local parseDynamic_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + parseDynamic("{1,2}") is Dynamic(this.toList() == List(1,2) && this.toMap().isEmpty) +// ^^^^^^^^^^^^ reference local parseDynamic_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#isEmpty. + parseDynamic("{a=1;b=2}") == new Dynamic { a = 1; b = 2 } +// ^^^^^^^^^^^^ reference local parseDynamic_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/b. + parseDynamic(#"{["a"]=1;["b"]=2}"#) == new Dynamic { a = 1; b = 2 } +// ^^^^^^^^^^^^ reference local parseDynamic_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/b. + parseDynamic("{[1]=1;[2]=2}") is Dynamic(this.toList() == List(1,2) && this.toMap().isEmpty) +// ^^^^^^^^^^^^ reference local parseDynamic_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#isEmpty. + parseDynamic("{[2]=2;[1]=1}") is Dynamic(this.toList() == List(1) && this.toMap() == Map(2,2)) +// ^^^^^^^^^^^^ reference local parseDynamic_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + parseDynamic("{[0]=1;[2]=2}") is Dynamic(this.toList().isEmpty && this.toMap() == Map(0,1,2,2)) +// ^^^^^^^^^^^^ reference local parseDynamic_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + parseDynamic("{[{}]=1}") == new Dynamic { [new Dynamic {}] = 1 } +// ^^^^^^^^^^^^ reference local parseDynamic_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + parseDynamic("{[{1,2}]=1}") == new Dynamic { [new Dynamic { 1; 2 }] = 1 } +// ^^^^^^^^^^^^ reference local parseDynamic_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + parseDynamic("{[{a=1}]=1}") == new Dynamic { [new Dynamic { a = 1 }] = 1 } +// ^^^^^^^^^^^^ reference local parseDynamic_30 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/a. + } + ["tables with useDynamic=false"] { + parseValue("{}") == new Listing {} +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + parseValue("{1,2}") == new Listing { 1; 2 } +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + parseValue("{a=1;b=2}") == new Mapping { ["a"] = 1; ["b"] = 2 } +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + parseValue(#"{["a"]=1;["b"]=2}"#) == new Mapping { ["a"] = 1; ["b"] = 2 } +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + parseValue("{[1]=1;[2]=2}") == new Listing { 1; 2 } +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + module.catch(() -> parseValue("{[2]=2;[1]=1}")).startsWith("Table has both list elements and map entries") +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#startsWith(). + parseValue("{[2]=1;[3]=2}") == new Mapping { [2] = 1; [3] = 2 } +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + parseValue("{[0]=1;[2]=2}") == new Mapping { [0] = 1; [2] = 2 } +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + parseValue("{[{}]=1}") == new Mapping { [new Listing {}] = 1 } +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + parseValue("{[{1,2}]=1}") == new Mapping { [new Listing { 1; 2 }] = 1 } +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + parseValue("{[{a=1}]=1}") == new Mapping { [new Mapping { ["a"] = 1 }] = 1 } +// ^^^^^^^^^^ reference local parseValue_25 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + } + ["_ENV[key] with useDynamic=true"] { + // note: new Dynamic { 1; 2 } == new Dynamic { [0] = 1; [1] = 2 }, so we have to take care with comparisons + parser.parse("_ENV[true]=1") == new Dynamic { [true] = 1 } +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + parser.parse(#"_ENV["foo"]=1"#) == new Dynamic { foo = 1 } +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/foo. + parser.parse("_ENV[1]=2") is Dynamic(this.toList() == List(2) && this.toMap().isEmpty) +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#isEmpty. + parser.parse("_ENV[0]=2") is Dynamic(this.toList().isEmpty && this.toMap() == Map(0, 2)) +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + parser.parse("_ENV[-1]=2") is Dynamic(this.toList().isEmpty && this.toMap() == Map(-1, 2)) +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + parser.parse("_ENV[2]=2;_ENV[1]=1") is Dynamic(this.toList() == List(1) && this.toMap() == Map(2,2)) +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + parser.parse("_ENV[{a=1}]=2") == new Dynamic { [new Dynamic { a = 1 }] = 2 } +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/a. + } + ["_ENV[key] with useDynamic=false"] { + local mapParser = (parser) { useDynamic = false } +// ^^^^^^^^^ definition local mapParser_108 +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/useDynamic. + mapParser.parse("_ENV[true]=1") == new Mapping { [true] = 1 } +// ^^^^^^^^^ reference local mapParser_108 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + mapParser.parse(#"_ENV["foo"]=1"#) == new Mapping { ["foo"] = 1 } +// ^^^^^^^^^ reference local mapParser_108 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + mapParser.parse("_ENV[1]=2") == new Mapping { [1] = 2 } +// ^^^^^^^^^ reference local mapParser_108 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + mapParser.parse("_ENV[0]=2") == new Mapping { [0] = 2 } +// ^^^^^^^^^ reference local mapParser_108 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + mapParser.parse("_ENV[-1]=2") == new Mapping { [-1] = 2 } +// ^^^^^^^^^ reference local mapParser_108 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + mapParser.parse("_ENV[2]=2;_ENV[1]=1") == new Mapping { [2] = 2; [1] = 1 } +// ^^^^^^^^^ reference local mapParser_108 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + mapParser.parse("_ENV[{a=1}]=2") == new Mapping { [new Mapping { ["a"] = 1 }] = 2 } +// ^^^^^^^^^ reference local mapParser_108 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + } + ["errors"] { + // these are facts instead of examples so we can preserve formatting in the error strings, since module.catch + // replaces newlines with spaces. + module.catch(() -> parser.parse("foo=")) == """ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + Expected value or {, found EOF + + 1 | foo= + | ^ + at :1:5 + """.replaceAll("\n", " ") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + module.catch(() -> parser.parse("foo=3\nbar=")) == """ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + Expected value or {, found EOF + + 2 | bar= + | ^ + at :2:5 + """.replaceAll("\n", " ") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + module.catch(() -> parser.parse(new Resource { text = "foo=1.2.3"; uri = "uri:path/to/input.lua" })) == """ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/text. +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/uri. + Invalid numeric literal: 1.2.3 + + 1 | foo=1.2.3 + | ^^^^^ + at uri:path/to/input.lua:1:5 + """.replaceAll("\n", " ") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + module.catch(() -> (parser) { useDynamic = false }.parse("foo={1, [true]=2}")) == """ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/useDynamic. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + Table has both list elements and map entries + + 1 | foo={1, [true]=2} + | ^ first list entry + | ^^^^ first map entry + at :1:6 + """.replaceAll("\n", " ") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + module.catch(() -> (parser) { useDynamic = false }.parse("foo={[true]=1, 2}")) == """ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/useDynamic. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + Table has both list elements and map entries + + 1 | foo={[true]=1, 2} + | ^^^^ first map entry + | ^ first list entry + at :1:7 + """.replaceAll("\n", " ") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + module.catch(() -> (parser) { useDynamic = false }.parse("foo={\n [true]=1;\n 2\n}")) == """ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/useDynamic. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + Table has both list elements and map entries + + 2 | [true]=1; + | ^^^^ first map entry + 3 | 2 + | ^ first list entry + at :2:4 + """.replaceAll("\n", " ") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + module.catch(() -> (parser) { useDynamic = false }.parse("foo={\n 1;\n [true]=2\n}")) == """ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/useDynamic. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + Table has both list elements and map entries + + 2 | 1; + | ^ first list entry + 3 | [true]=2 + | ^^^^ first map entry + at :2:3 + """.replaceAll("\n", " ") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + module.catch(() -> parser.parse("[1]=1")) == """ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + Expected identifier or ;, found token `[` + + 1 | [1]=1 + | ^ + at :1:1 + """.replaceAll("\n", " ") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + module.catch(() -> parser.parse("_ENV=1")) == """ +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + _ENV cannot be assigned to directly + + 1 | _ENV=1 + | ^ + at :1:5 + """.replaceAll("\n", " ") +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). + } + } + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/examples. + ["empty"] { + parser.parse("") +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + } + ["null"] { + parser.parse("foo=nil") +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + } + ["boolean"] { + parser.parse("foo=true\nbar=false") +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + } + ["number"] { + parser.parse(""" +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + zero=0 + one=1 + negative=-1 + maxInt32=2147483647 + minInt32=-2147483648 + zerof=0.0 + float=5.32 + negfloat=-10.26 + hex=0xaBcD + hexf=0X80.0 + hexf2=0x80.8 -- 128.5 + hexf3=0x7f.f0 -- 127.9375 + hexf4=0x7f.84 -- 127.515625 + hexf5=0x7f.abc -- 127.6708984375 + hexp=0x1p1 -- 2.0 + hexp=0x1p+1 -- 2.0 + hexp2=0x1p2 -- 4.0 + hexp3=0x1p-1 -- 0.5 + hexp4=0x80.8p1 -- 257.0 + """) + } + ["string"] { + parser.parse(#""" +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + s="hello world" + single = 'one\'two' + -- line comment + double = "one\"two" + --[[ + long comment + ]] + escapes = "\a\b\f\n\r\t\v" + hex = --[=[ comment]] ]=] "\x00\x3a\x3A\x7f" + dec = "\0\58\058\0580\127" + u = "\u{0}\u{300a}\u{300B}\u{10FFFF}" + newline = "foo\ + bar" + z = "foo\z + bar" + long=[[foo]] + long2=[[ + foo]] + long3=[[ + foo]] + long4=[=[]]]=] + long5=[===[]==]]====]]===] + """#) + } + ["class converters"] { + (parser) { converters { [Int] = (it) -> it + 1 } }.parse("foo=1;bar=2;baz=1.0") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_252 +// ^^ reference local it_252 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [Int] = (it) -> it + 1 } }.parse("foo={1, 2}") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_253 +// ^^ reference local it_253 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [Int] = (it) -> it + 1 } }.parse("foo={[1]=1;[2]=2}") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_254 +// ^^ reference local it_254 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [Int] = (it) -> it + 1 } }.parse("foo={[2]=2;[3]=3}") // not listing elements! +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_255 +// ^^ reference local it_255 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [Int] = (it) -> it + 1 } }.parse("_ENV[1]=1;_ENV[2]=2") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_256 +// ^^ reference local it_256 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [Int] = (it) -> it + 1 } }.parse("_ENV[2]=2;_ENV[3]=3") // not listing elements! +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_257 +// ^^ reference local it_257 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [String] = (it) -> "\(it)!" } }.parse(#"foo="bar""#) +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^ definition local it_258 +// ^^ reference local it_258 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [String] = (it) -> "\(it)!" } }.parse(#"_ENV["foo"]="bar""#) +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^ definition local it_259 +// ^^ reference local it_259 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + fixupTableKeys((parser) { converters { [String] = (it) -> "\(it)!" } }.parse(#"table={["foo"]="bar"}"#)) +// ^^^^^^^^^^^^^^ reference local fixupTableKeys_307 +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^ definition local it_260 +// ^^ reference local it_260 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + fixupTableKeys((parser) { converters { [Int] = (it) -> it + 1 } }.parse("_ENV[{a=1}]=true")) +// ^^^^^^^^^^^^^^ reference local fixupTableKeys_307 +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_261 +// ^^ reference local it_261 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [Dynamic] = (it) -> (it) { done = true } } }.parse("foo=1") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^ definition local it_262 +// ^^ reference local it_262 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/done. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + } + ["path converters"] { + (parser) { converters { ["^"] = (it) -> (it) { done = true } } }.parse("foo=1") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_265 +// ^^ reference local it_265 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/done. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [""] = (it) -> (it) { done = true } } }.parse("foo=1") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_266 +// ^^ reference local it_266 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/done. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { ["foo"] = (it) -> it + 1 } }.parse("foo=1") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_267 +// ^^ reference local it_267 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { ["^foo"] = (it) -> it + 1 } }.parse("foo=1") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_268 +// ^^ reference local it_268 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { ["a.foo"] = (it) -> it + 1 } }.parse("foo=1") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_269 +// ^^ reference local it_269 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { ["foo.a"] = (it) -> it + 1 } }.parse("foo={a=1;b=2}") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_270 +// ^^ reference local it_270 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { ["^a"] = (it) -> it + 1 } }.parse("a=1;foo={a=1}") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_271 +// ^^ reference local it_271 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { ["*"] = (it) -> it + 1 } }.parse("a=1;_ENV[true]=1") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_272 +// ^^ reference local it_272 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { ["[*]"] = (it) -> it + 1 } }.parse(#"a=1;_ENV["b"]=1;_ENV[true]=1"#) +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_273 +// ^^ reference local it_273 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { useDynamic = false; converters { ["[*]"] = (it) -> it + 1 } }.parse(#"foo={a=1;["b"]=1;[true]=1}"#) +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/useDynamic. +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_274 +// ^^ reference local it_274 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + } + ["path converters apply after converting keys"] { + // first validate that paths "x[42]" and "x.42" won't match an integral key + (parser) { converters { ["x[42]"] = (it) -> "matched: \(it)"; ["x.42"] = (it) -> "matched: \(it)" } }.parse("x={[42]=true}") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_278 +// ^^ reference local it_278 +// ^^ definition local it_278 +// ^^ reference local it_278 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + // and validate that the path "x.42" will match a string key + (parser) { converters { ["x.42"] = (it) -> "matched: \(it)" } }.parse(#"x={["42"]=true}"#) +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_280 +// ^^ reference local it_280 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + // now if we convert the integral key to a string, it should match "x.42" + (parser) { converters { [Int] = (it) -> it.toString(); ["x.42"] = (it) -> "matched: \(it)" } }.parse("x={[42]=true}") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_282 +// ^^ reference local it_282 +// ^^ definition local it_282 +// ^^ reference local it_282 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + } + ["path converters in tables as table keys"] { + fixupTableKeys((parser) { converters { ["^"] = (it) -> (it) { done = true } } }.parse("_ENV[{a=1}]=1")) // ^ doesn't match the key table +// ^^^^^^^^^^^^^^ reference local fixupTableKeys_307 +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_285 +// ^^ reference local it_285 +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/done. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + fixupTableKeys((parser) { converters { ["a"] = (it) -> it + 1 } }.parse("_ENV[{a=1;b=1}]=1;a=1")) +// ^^^^^^^^^^^^^^ reference local fixupTableKeys_307 +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_286 +// ^^ reference local it_286 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + fixupTableKeys((parser) { converters { ["^a"] = (it) -> it + 1 } }.parse("_ENV[{a=1;b=1}]=1;a=1")) // ^ doesn't match the key table +// ^^^^^^^^^^^^^^ reference local fixupTableKeys_307 +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_287 +// ^^ reference local it_287 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + fixupTableKeys((parser) { converters { ["a.b"] = (it) -> it + 1 } }.parse("foo={[{a={b=1};b=1}]=1}")) +// ^^^^^^^^^^^^^^ reference local fixupTableKeys_307 +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_288 +// ^^ reference local it_288 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + } + ["converters can return non-Lua types"] { + (parser) { converters { ["^"] = (it) -> Pair("foo", it.foo) } }.parse("foo=1") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^ definition local it_291 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^ reference local it_291 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [Int] = (it) -> Pair("int", it) } }.parse("foo=1") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_292 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^ reference local it_292 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [Int] = (it) -> Pair("int", it) } }.parse("_ENV[5]=true") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_293 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^ reference local it_293 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [Int] = (it) -> Pair("int", it) } }.parse("foo={[5]=true}") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_294 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^ reference local it_294 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [Int] = (it) -> Pair("int", it) }; useDynamic = false }.parse("_ENV[5]=true") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_295 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^ reference local it_295 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/useDynamic. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + (parser) { converters { [Int] = (it) -> Pair("int", it) }; useDynamic = false }.parse("foo={[5]=true}") +// ^^^^^^ reference local parser_23 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/converters. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_296 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). +// ^^ reference local it_296 +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/useDynamic. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + } + ["fixtures"] { + fixupTableKeys(parser.parse(read("fixtures/sample.lua"))) +// ^^^^^^^^^^^^^^ reference local fixupTableKeys_307 +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + parser.parse(read("fixtures/comment.lua")) +// ^^^^^^ reference local parser_23 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Parser#parse(). + } + } + + // When rendering parser.pkl-actual.pcf, any table keys that are objects just render as `new { … }`, and this produces + // an error "Cannot tell which parent to amend". This function replaces any such keys with a rendered string. This does + // mean that parser.pkl-expected.pcf needs to use rendered strings here instead. + local function fixupTableKeys(value: Dynamic|Mapping|Listing): Dynamic|Mapping|Listing = +// ^^^^^^^^^^^^^^ definition local fixupTableKeys_307 +// ^^^^^ definition local value_307 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + if (value is Listing) +// ^^^^^ reference local value_307 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + value.toList().map((v) -> +// ^^^^^ reference local value_307 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local v_309 + if (v is Dynamic|Mapping|Listing) fixupTableKeys(v) +// ^ reference local v_309 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference local fixupTableKeys_307 +// ^ reference local v_309 + else v +// ^ reference local v_309 + ).toListing() +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toListing(). + else + let (mapf = (k, v) -> Pair( +// ^^^^ definition local mapf_314 +// ^ definition local k_314 +// ^ definition local v_314 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair(). + if (k is Object) "new \(k.getClass().simpleName) \(new PcfRenderer { indent = "" }.renderValue(k).replaceAll("\n", " "))" else k, +// ^ reference local k_314 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Object# +// ^ reference local k_314 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class#simpleName. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer# +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/parser.pkl`/indent. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/PcfRenderer#renderValue(). +// ^ reference local k_314 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#replaceAll(). +// ^ reference local k_314 + if (v is Dynamic|Mapping|Listing) fixupTableKeys(v) else v +// ^ reference local v_314 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^^^^^^^ reference local fixupTableKeys_307 +// ^ reference local v_314 +// ^ reference local v_314 + )) + let (valueMap = value.toMap()) +// ^^^^^^^^ definition local valueMap_318 +// ^^^^^ reference local value_307 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + if (value is Dynamic) +// ^^^^^ reference local value_307 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + let (map1 = valueMap.filter((k,_) -> !(k is Object)).map(mapf)) +// ^^^^ definition local map1_320 +// ^^^^^^^^ reference local valueMap_318 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^ definition local k_320 +// ^ reference local k_320 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Object# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#map(). +// ^^^^ reference local mapf_314 + let (map2 = valueMap.filter((k,_) -> k is Object).map(mapf)) +// ^^^^ definition local map2_321 +// ^^^^^^^^ reference local valueMap_318 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^ definition local k_321 +// ^ reference local k_321 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Object# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#map(). +// ^^^^ reference local mapf_314 + (map1.toDynamic()) { +// ^^^^ reference local map1_320 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toDynamic(). + ...map2 +// ^^^^ reference local map2_321 + ...value.toList() +// ^^^^^ reference local value_307 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). + } + else valueMap.map(mapf).toMapping() +// ^^^^^^^^ reference local valueMap_318 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#map(). +// ^^^^ reference local mapf_314 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#toMapping(). + diff --git a/pkl-pantrysnapshot/pkl.lua/tests/renderer.pkl b/pkl-pantrysnapshot/pkl.lua/tests/renderer.pkl new file mode 100755 index 00000000..4bb84741 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.lua/tests/renderer.pkl @@ -0,0 +1,1290 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.lua.tests.renderer +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/ + + amends "pkl:test" + + import "../lua.pkl" + + local function RenderDirective(text_: String): RenderDirective = new { text = text_ } +// ^^^^^^^^^^^^^^^ definition local RenderDirective_22 +// ^^^^^ definition local text__22 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/RenderDirective# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/text. +// ^^^^^ reference local text__22 + local function LuaRenderDirective(before_: String?, value_: Any, after_: String?): lua.RenderDirective = new { before = before_; value = value_; after = after_ } +// ^^^^^^^^^^^^^^^^^^ definition local LuaRenderDirective_23 +// ^^^^^^^ definition local before__23 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ definition local value__23 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^ definition local after__23 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/RenderDirective# +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/before. +// ^^^^^^^ reference local before__23 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/value. +// ^^^^^^ reference local value__23 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/after. +// ^^^^^^ reference local after__23 + + facts { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/facts. + ["base.RenderDirective"] { + new lua.Renderer {}.renderDocument(RenderDirective("foo")) == "foo\n" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^^^^^^^^ reference local RenderDirective_22 + new lua.Renderer {}.renderDocument(new Dynamic { [RenderDirective("foo bar")] = 1}) == "foo bar = 1\n" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^^^^^^ reference local RenderDirective_22 + new lua.Renderer {}.renderValue(Map(RenderDirective("a.b"), 1)) == "{ a.b = 1; }" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^^^^^^^^^^ reference local RenderDirective_22 + new lua.Renderer {}.renderValue(Map(RenderDirective("]["), 1)) == "{ ][ = 1; }" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^^^^^^^^^^ reference local RenderDirective_22 + new lua.Renderer {}.renderValue(Map(RenderDirective("a"), 1)) == #"{ a = 1; }"# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^^^^^^^^^^ reference local RenderDirective_22 + new lua.Renderer {}.renderValue(List(1, RenderDirective("foo bar"), 2)) == "{ 1, foo bar, 2 }" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^^^^^^^^^^^^ reference local RenderDirective_22 + new lua.Renderer {}.renderValue(Map("a", RenderDirective("1 + 2"))) == "{ a = 1 + 2; }" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). +// ^^^^^^^^^^^^^^^ reference local RenderDirective_22 + new lua.Renderer { multilineThreshold = 1 }.renderValue(new Dynamic { a { [RenderDirective("a\nb")] = RenderDirective("c\nd") }}) == "{\n a = {\n a\nb = c\nd;\n };\n}" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/multilineThreshold. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^^^^^^^^^ reference local RenderDirective_22 +// ^^^^^^^^^^^^^^^ reference local RenderDirective_22 + } + ["lua.RenderDirective"] { + new lua.Renderer {}.renderDocument(LuaRenderDirective(null, 1, null)) == "1\n" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^^^^^^^^^^^ reference local LuaRenderDirective_23 + new lua.Renderer {}.renderDocument(LuaRenderDirective(null, new Dynamic { a = 1 }, null)) == "{ a = 1; }\n" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^^^^^^^^^^^ reference local LuaRenderDirective_23 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + new lua.Renderer {}.renderDocument(LuaRenderDirective("x", new Dynamic { a = 1 }, "y")) == "x{ a = 1; }y\n" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^^^^^^^^^^^ reference local LuaRenderDirective_23 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + new lua.Renderer {}.renderDocument(new Dynamic { a = LuaRenderDirective(null, 1, null) }) == "a = 1\n" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^^^^^^^^^^^^ reference local LuaRenderDirective_23 + new lua.Renderer {}.renderDocument(new Dynamic { a = LuaRenderDirective("x", 1, "y") }) == "a = x1y\n" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^^^^^^^^^^^^ reference local LuaRenderDirective_23 + new lua.Renderer {}.renderDocument(new Dynamic { [LuaRenderDirective(null, "a", null)] = 1 }) == #"_ENV["a"] = 1\#n"# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^^^^^^^^^ reference local LuaRenderDirective_23 + new lua.Renderer {}.renderDocument(new Dynamic { [LuaRenderDirective("x", "a", "y")] = 1 }) == #"_ENV[x"a"y] = 1\#n"# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^^^^^^^^^ reference local LuaRenderDirective_23 + new lua.Renderer {}.renderDocument(new Dynamic { [LuaRenderDirective("x", RenderDirective("a"), "y")] = 1 }) == #"_ENV[xay] = 1\#n"# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^^^^^^^^^ reference local LuaRenderDirective_23 +// ^^^^^^^^^^^^^^^ reference local RenderDirective_22 + new lua.Renderer {}.renderValue(new Dynamic { [LuaRenderDirective(null, "a", null)] = 1 }) == #"{ ["a"] = 1; }"# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^^^^^^^^^ reference local LuaRenderDirective_23 + new lua.Renderer {}.renderValue(new Dynamic { [LuaRenderDirective("x", "a", "y")] = 1 }) == #"{ [x"a"y] = 1; }"# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^^^^^^^^^ reference local LuaRenderDirective_23 + new lua.Renderer {}.renderValue(new Dynamic { [LuaRenderDirective("x", RenderDirective("a"), "y")] = 1 }) == #"{ [xay] = 1; }"# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^^^^^^^^^ reference local LuaRenderDirective_23 +// ^^^^^^^^^^^^^^^ reference local RenderDirective_22 + } + ["Lua indexes are 1-based"] { + new lua.Renderer {}.renderDocument(new Dynamic { 1; 2 }) == "_ENV[1] = 1\n_ENV[2] = 2\n" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + } + ["omitNullProperties"] { + new lua.Renderer { omitNullProperties = true }.renderDocument(new Dynamic { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/omitNullProperties. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + type = "Dynamic" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/type. + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + b = null +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. + ["c"] = null // language limitation means this is treated like a property + [42] = null + [true] = null + nest { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/nest. + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + b = null +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. + ["c"] = null // language limitation means this is treated like a property + [42] = null + [true] = null + mapping = new Mapping { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/mapping. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["a"] = 1 + ["b"] = null + [42] = null + [true] = null + } + map = Map("a", 1, "b", null) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/map. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + listing = new Listing { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/listing. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + 1 + null + } + list = List(1, null) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/list. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + } + foo = new Foo { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/foo. +// ^^^ reference local Foo_322 + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + } + }) == new lua.Renderer {}.renderDocument(new Dynamic { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + type = "Dynamic" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/type. + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + [42] = null + [true] = null + nest { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/nest. + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + [42] = null + [true] = null + mapping = new Mapping { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/mapping. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["a"] = 1 + ["b"] = null + [42] = null + [true] = null + } + map = Map("a", 1, "b", null) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/map. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + listing = new Listing { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/listing. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + 1 + null + } + list = List(1, null) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/list. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + } + foo { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/foo. + type = "class Foo" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/type. + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + } + }) + new lua.Renderer { omitNullProperties = true }.renderDocument(new Mapping { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/omitNullProperties. +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["type"] = "Mapping" + ["a"] = 1 + ["b"] = null // this is a Mapping, it won't be omitted + ["dynamic"] { + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + b = null +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. + ["c"] = null // language limitation means this is treated like a property + } + ["foo"] = new Foo { +// ^^^ reference local Foo_322 + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + } + }) == new lua.Renderer {}.renderDocument(new Mapping { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["type"] = "Mapping" + ["a"] = 1 + ["b"] = null + ["dynamic"] { + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + } + ["foo"] { + type = "class Foo" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/type. + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + } + }) + } + ["default key"] { + // A Typed with a `default` key should render just fine even though Dynamic has `hidden default` + local renderer = new lua.Renderer { omitNullProperties = true } +// ^^^^^^^^ definition local renderer_136 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/omitNullProperties. + // Check Dynamic with ["default"] first so ensure we can use Dynamic to generate valid cases + renderer.renderDocument(new Dynamic { ["default"] = 1 }) == "default = 1\n" +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + renderer.renderValue(new Dynamic { ["default"] = 1 }) == "{ default = 1; }" +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + // Now everything else can just validate against the equivalent Dynamic + // Note that we need to use entries exclusively for ordering reasons + renderer.renderDocument(new WithDefault { default = 1 }) == renderer.renderDocument(new Dynamic { ["default"] = 1 }) +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^^^^ reference local WithDefault_329 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/default. +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + renderer.renderDocument(new WithDefault { default = 1; a = 2 }) == renderer.renderDocument(new Dynamic { ["default"] = 1; ["a"]= 2 }) +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^^^^ reference local WithDefault_329 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/default. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + renderer.renderDocument(new Dynamic { a = new WithDefault { default = 1 } }) == renderer.renderDocument(new Dynamic { ["a"] { ["default"] = 1 } }) +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^^^^^ reference local WithDefault_329 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/default. +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + renderer.renderDocument(new Dynamic { a = new WithDefault { default = 1; a = 2 } }) == renderer.renderDocument(new Dynamic { ["a"] { ["default"] = 1; ["a"] = 2 } }) +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^^^^^ reference local WithDefault_329 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/default. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + renderer.renderValue(new WithDefault { default = 1 }) == renderer.renderValue(new Dynamic { ["default"] = 1 }) +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^^^^^ reference local WithDefault_329 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/default. +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + renderer.renderValue(new WithDefault { default = 1; a = 2 }) == renderer.renderValue(new Dynamic { ["default"] = 1; ["a"] = 2 }) +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^^^^^ reference local WithDefault_329 +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/default. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^^ reference local renderer_136 +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + } + ["path converters"] { + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["^"] = (_) -> new Dynamic { a = 1 } +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + } + }.renderDocument(new Dynamic { b = 2 }) == "a = 1\n" +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + [""] = (_) -> new Dynamic { a = 1 } +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + } + }.renderDocument(new Dynamic { b = 2 }) == "a = 1\n" +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["*"] = (it) -> if (it is Int) it + 1 else it +// ^^ definition local it_162 +// ^^ reference local it_162 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ reference local it_162 +// ^^ reference local it_162 + } + }.renderDocument(new Dynamic { 1; a = 1; b { 1; c = 1; d { e = 1 } } }) == new lua.Renderer {}.renderDocument(new Dynamic { 1; a = 2; b { 1; c = 2; d { e = 2 } } }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/d. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/e. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/d. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/e. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["a.b"] = (it) -> it + 1 +// ^^ definition local it_167 +// ^^ reference local it_167 + } + }.renderDocument(new Dynamic { a { b = 1; c { b = 1 } }; b = 1; c { a { b = 1 } } }) == new lua.Renderer {}.renderDocument(new Dynamic { a { b = 2; c { b = 1 } }; b = 1; c { a { b = 2 } } }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["^a.b"] = (it) -> it + 1 +// ^^ definition local it_172 +// ^^ reference local it_172 + } + }.renderDocument(new Dynamic { a { b = 1; c { b = 1 } }; b = 1; c { a { b = 1 } } }) == new lua.Renderer {}.renderDocument(new Dynamic { a { b = 2; c { b = 1 } }; b = 1; c { a { b = 1 } } }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["a"] = (it) -> new Dynamic { b = it } +// ^^ definition local it_177 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^^ reference local it_177 + ["b"] = (it) -> new Dynamic { c = it } +// ^^ definition local it_178 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^^ reference local it_178 + } + }.renderDocument(new Dynamic { a = 1 }) == new lua.Renderer {}.renderDocument(new Dynamic { a { b { c = 1 } } }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["[*]"] = (it) -> if (it is Int) it + 1 else it +// ^^ definition local it_183 +// ^^ reference local it_183 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ reference local it_183 +// ^^ reference local it_183 + } + }.renderDocument(new Mapping { ["a"] = 1; ["b"] = new Mapping { ["c"] = 1 } }) == new lua.Renderer {}.renderDocument(new Dynamic { a = 2; b { c = 2 } }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["[*]"] = (it) -> if (it is Int) it + 1 else it +// ^^ definition local it_188 +// ^^ reference local it_188 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ reference local it_188 +// ^^ reference local it_188 + } + }.renderDocument(new Dynamic { a = 1; 1; new Listing { 1; 2 }; 2 }) == new lua.Renderer {}.renderDocument(new Dynamic { a = 1; 2; new Listing { 2; 3 }; 3 }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["[a]"] = (it) -> it + 1 +// ^^ definition local it_193 +// ^^ reference local it_193 + } + }.renderDocument(new Dynamic { a = 1; map = new Mapping { ["a"] = 1 } }) == new lua.Renderer {}.renderDocument(new Dynamic { a = 1; map { ["a"] = 2 } }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/map. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/map. + // check that path like "[1]" matches string key "1" and not list idx or int key or funky property + let (source = new Dynamic { 1; 1; new Dynamic { 1; 1 }; new Listing { 1; 1 }; new Mapping { [1] = 1; ["1"] = 1 }; new Dynamic { `[1]` = 1; `["1"]` = 1 } }) +// ^^^^^^ definition local source_197 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/`[1]`. +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/`["1"]`. + let (expected = new Dynamic { 1; 1; new Dynamic { 1; 1 }; new Listing { 1; 1 }; new Mapping { [1] = 1; ["1"] = 2 }; new Dynamic { `[1]` = 1; `["1"]` = 1 } }) +// ^^^^^^^^ definition local expected_198 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/`[1]`. +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/`["1"]`. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["[1]"] = (it) -> it + 1 +// ^^ definition local it_201 +// ^^ reference local it_201 + } + }.renderDocument(source) == new lua.Renderer {}.renderDocument(expected) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^ reference local source_197 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^ reference local expected_198 + // check for string vs int key on Dynamic too; note that Dynamic treats all string keys as properties, so the converter shouldn't run + let (source = new Dynamic { [1] = 1; ["1"] = 1; nest { [1] = 1; ["1"] = 1 } }) +// ^^^^^^ definition local source_205 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/nest. + let (expected = new Dynamic { [1] = 1; ["1"] = 1; nest { [1] = 1; ["1"] = 1 } }) +// ^^^^^^^^ definition local expected_206 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/nest. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["[1]"] = (it) -> it + 1 +// ^^ definition local it_209 +// ^^ reference local it_209 + } + }.renderDocument(source) == new lua.Renderer {}.renderDocument(expected) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^ reference local source_205 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^ reference local expected_206 + } + ["path converters apply after converting keys"] { + // first validate that "x.42" matches a string key but not an integral key, and "x[42]" doesn't match + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["x[42]"] = (it) -> "unexpected match: \(it)" +// ^^ definition local it_217 +// ^^ reference local it_217 + ["x.42"] = (it) -> "matched: \(it)" +// ^^ definition local it_218 +// ^^ reference local it_218 + } + }.renderDocument(new Dynamic { x { [42] = true; ["42"] = true } }) == new lua.Renderer {}.renderDocument(new Dynamic { x { [42] = true; ["42"] = "matched: true" } }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/x. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/x. + // now validate that converting the key makes it match "x[42]" instead of "x.42" (as we know it's a key, not a property) + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + [Int] = (it) -> it.toString() +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_224 +// ^^ reference local it_224 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + ["x.42"] = (it) -> "unexpected match: \(it)" +// ^^ definition local it_225 +// ^^ reference local it_225 + ["x[42]"] = (it) -> "matched: \(it)" +// ^^ definition local it_226 +// ^^ reference local it_226 + } + }.renderDocument(new Dynamic { x { [42] = true } }) == new lua.Renderer {}.renderDocument(new Dynamic { x { ["42"] = "matched: true" } }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/x. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/x. + // same thing with Mapping, validate that "x[42]" matches a string key but not an integral key, and "x.42" doesn't match + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["x.42"] = (it) -> "unexpected match: \(it)" +// ^^ definition local it_232 +// ^^ reference local it_232 + ["x[42]"] = (it) -> "matched: \(it)" +// ^^ definition local it_233 +// ^^ reference local it_233 + } + }.renderDocument(new Dynamic { x = new Mapping { [42] = true; ["42"] = true } }) == new lua.Renderer {}.renderDocument(new Dynamic { x { [42] = true; ["42"] = "matched: true" } }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/x. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/x. + // now validate that converting the key makes it match "x[42]" (but not "x.42") + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + [Int] = (it) -> it.toString() +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_239 +// ^^ reference local it_239 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int#toString(). + ["x.42"] = (it) -> "unexpected match: \(it)" +// ^^ definition local it_240 +// ^^ reference local it_240 + ["x[42]"] = (it) -> "matched: \(it)" +// ^^ definition local it_241 +// ^^ reference local it_241 + } + }.renderDocument(new Dynamic { x = new Mapping { [42] = true } }) == new lua.Renderer {}.renderDocument(new Dynamic { x { ["42"] = "matched: true" } }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/x. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/x. + } + ["path converters in objects used as mapping keys"] { + let (source = new Dynamic { a = 1; [new Dynamic { a = 1; b { a = 1; c = 1 }; c = 1 }] = 1 }) +// ^^^^^^ definition local source_246 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. + let (expected = new Dynamic { a = 11; [new Dynamic { a = 2; b { a = 2; c = 3 }; c = 1 }] = 1 }) +// ^^^^^^^^ definition local expected_247 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["^a"] = (it) -> it + 10 // ^ won't match in table key +// ^^ definition local it_250 +// ^^ reference local it_250 + ["a"] = (it) -> it + 1 +// ^^ definition local it_251 +// ^^ reference local it_251 + ["b.c"] = (it) -> it + 2 +// ^^ definition local it_252 +// ^^ reference local it_252 + } + }.renderDocument(source) == new lua.Renderer {}.renderDocument(expected) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^ reference local source_246 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^ reference local expected_247 + let (source = new Dynamic { foo { a = 1; [new Dynamic { a = 1; b { a = 1; c = 1 }; c = 1 }] = 1 } }) +// ^^^^^^ definition local source_255 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/foo. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. + let (expected = new Dynamic { foo { a = 11; [new Dynamic { a = 2; b { a = 2; c = 3 }; c = 1 }] = 1 } }) +// ^^^^^^^^ definition local expected_256 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/foo. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + ["^*.a"] = (it) -> it + 10 // ^ won't match in table key +// ^^ definition local it_259 +// ^^ reference local it_259 + ["a"] = (it) -> it + 1 +// ^^ definition local it_260 +// ^^ reference local it_260 + ["b.c"] = (it) -> it + 2 +// ^^ definition local it_261 +// ^^ reference local it_261 + } + }.renderDocument(source) == new lua.Renderer {}.renderDocument(expected) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^ reference local source_255 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^ reference local expected_256 + } + ["class converters"] { + let (source = new Dynamic { a = 1; b = "two"; c = true; nest { 1; "one"; a = 1; b = "two"; c = true }; map = new Mapping { ["a"] = 1; ["b"] = "two"; ["c"] = true }; list = new Listing { 1; "two"; true } }) +// ^^^^^^ definition local source_266 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/nest. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/map. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/list. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + let (expected = new Dynamic { a = 2; b = "two!"; c = true; nest { 2; "one!"; a = 2; b = "two!"; c = true }; map { ["a!"] = 2; ["b!"] = "two!"; ["c!"] = true }; list { 2; "two!"; true } }) +// ^^^^^^^^ definition local expected_267 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/nest. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/map. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/list. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + [Int] = (it) -> it + 1 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_270 +// ^^ reference local it_270 + [String] = (it) -> "\(it)!" +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^ definition local it_271 +// ^^ reference local it_271 + } + }.renderDocument(source) == new lua.Renderer {}.renderDocument(expected) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^ reference local source_266 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^ reference local expected_267 + // class converters prefer the most specific class + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + [Base] = (_) -> "base" +// ^^^^ reference local Base_334 + [Child] = (_) -> "child" +// ^^^^^ reference local Child_335 + } + }.renderDocument(new Dynamic { base = new Base {}; child = new Child {} }) == new lua.Renderer {}.renderDocument(new Dynamic { base = "base"; child = "child" }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/base. +// ^^^^ reference local Base_334 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/child. +// ^^^^^ reference local Child_335 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/base. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/child. + // class converters match subclasses + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + [Base] = (_) -> "base" +// ^^^^ reference local Base_334 + } + }.renderDocument(new Dynamic { child = new Child {} }) == new lua.Renderer {}.renderDocument(new Dynamic { child = "base" }) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/child. +// ^^^^^ reference local Child_335 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/child. + } + ["class converters in mapping keys"] { + // remember, string mapping keys in Dynamic are treated as properties + let (source = new Dynamic { [5] = 1; ["a"] = true; foo { [5] = 1; ["a"] = true }; map = new Mapping { [5] = 1; ["a"] = true } }) +// ^^^^^^ definition local source_290 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/foo. +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/map. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + let (expected = new Dynamic { [6] = 2; ["a"] = true; foo { [6] = 2; ["a"] = true }; map { [6] = 2; ["a!"] = true } }) +// ^^^^^^^^ definition local expected_291 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/foo. +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/map. + new lua.Renderer { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/converters. + [Int] = (it) -> it + 1 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# +// ^^ definition local it_294 +// ^^ reference local it_294 + [String] = (it) -> "\(it)!" +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^ definition local it_295 +// ^^ reference local it_295 + } + }.renderDocument(source) == new lua.Renderer {}.renderDocument(expected) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^ reference local source_290 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^^ reference local expected_291 + } + ["NaN and Infinity"] { + new lua.Renderer {}.renderValue(Infinity) == "(1/0)" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Infinity. + new lua.Renderer {}.renderValue(-Infinity) == "(-1/0)" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Infinity. + new lua.Renderer {}.renderValue(NaN) == "(0/0)" +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/NaN. + } + ["table keys can be anything but nil or NaN"] { + // check all other types first + module.catchOrNull(() -> new lua.Renderer {}.renderDocument(new Dynamic { [1] = 1; [1.0] = 1; [Infinity] = 1; ["a"] = 1; [true] = 1; [Map()] = 1})) == null +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Infinity. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + module.catchOrNull(() -> new lua.Renderer {}.renderDocument(new Mapping { [1] = 1; [1.0] = 1; [Infinity] = 1; ["a"] = 1; [true] = 1; [Map()] = 1})) == null +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Infinity. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + module.catchOrNull(() -> new lua.Renderer {}.renderValue(new Dynamic { [1] = 1; [1.0] = 1; [Infinity] = 1; ["a"] = 1; [true] = 1; [Map()] = 1})) == null +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Infinity. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + module.catchOrNull(() -> new lua.Renderer {}.renderValue(new Mapping { [1] = 1; [1.0] = 1; [Infinity] = 1; ["a"] = 1; [true] = 1; [Map()] = 1})) == null +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catchOrNull(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Infinity. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + module.catch(() -> new lua.Renderer {}.renderDocument(new Dynamic { [null] = 1 })) == "Lua table keys cannot be null" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + module.catch(() -> new lua.Renderer {}.renderDocument(new Dynamic { [NaN] = 1 })) == "Lua table keys cannot be NaN" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/NaN. + module.catch(() -> new lua.Renderer {}.renderDocument(new Mapping { [null] = 1 })) == "Lua table keys cannot be null" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + module.catch(() -> new lua.Renderer {}.renderDocument(new Mapping { [NaN] = 1 })) == "Lua table keys cannot be NaN" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/NaN. + module.catch(() -> new lua.Renderer {}.renderValue(new Dynamic { [null] = 1 })) == "Lua table keys cannot be null" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + module.catch(() -> new lua.Renderer {}.renderValue(new Dynamic { [NaN] = 1 })) == "Lua table keys cannot be NaN" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/NaN. + module.catch(() -> new lua.Renderer {}.renderValue(new Mapping { [null] = 1 })) == "Lua table keys cannot be null" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + module.catch(() -> new lua.Renderer {}.renderValue(new Mapping { [NaN] = 1 })) == "Lua table keys cannot be NaN" +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.test`/catch(). +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/NaN. + } + } + + // Helper class for tests + local class Foo { +// ^^^ definition local Foo_322 + fixed type = "class Foo" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/Foo#type. + a: Int? +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/Foo#a. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Int# + b: String? +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/Foo#b. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + // Helper class for tests + local class WithDefault { +// ^^^^^^^^^^^ definition local WithDefault_329 + default: Any +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/WithDefault#default. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + a: Any? +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/WithDefault#a. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + } + + local open class Base {} +// ^^^^ definition local Base_334 + local class Child extends Base {} +// ^^^^^ definition local Child_335 +// ^^^^ reference local Base_334 + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/examples. + ["default render document"] { + new lua.Renderer {}.renderDocument(new Dynamic { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + int = 1 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/int. + float = 1.0 +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/float. + string = "two" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/string. + bool = true +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/bool. + `null` = null +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/null. + list = List(1, 2, 3) +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/list. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + listing = new Listing { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/listing. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + "one" + "two" + "three" + } + map = Map("a", 1, "b", 2) +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/map. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + mapping = new Mapping { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/mapping. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["a"] = 1 + ["b"] = 2 + } + dynamic { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/dynamic. + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + b = 2 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. + nested { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/nested. + c = 3 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/c. + d = 4 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/d. + } + } + foo = new Foo { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/foo. +// ^^^ reference local Foo_322 + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + } + }) + new lua.Renderer {}.renderDocument(new Dynamic { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + a = 1 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + ["b"] = 2 + "three" + `weird-key` = "hello" +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/weird-key. + fáncy = true +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/`fáncy`. + `if` = "keyword" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/if. + [""] = null + }) + new lua.Renderer {}.renderDocument(new Mapping { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["a"] = 1 + ["b"] = 2 + ["weird key"] = 3 + [""] = null + }) + new lua.Renderer {}.renderDocument(new Foo { a = 1 }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^ reference local Foo_322 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + } + ["default render value"] { + new lua.Renderer {}.renderValue(123) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). + new lua.Renderer {}.renderValue(123.5) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). + new lua.Renderer {}.renderValue("hello") +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). + new lua.Renderer {}.renderValue(new Listing { 1; 2; 3 }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + new lua.Renderer {}.renderValue(List(1, 2, 3)) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + new lua.Renderer {}.renderValue(new Mapping { ["a"] = 1; ["b"] = 2 }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + new lua.Renderer {}.renderValue(Map("a", 1, "b", 2)) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + new lua.Renderer {}.renderValue(null) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). + new lua.Renderer {}.renderValue(true) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). + new lua.Renderer {}.renderValue(new Dynamic { a = 1; b = 2 }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. + new lua.Renderer {}.renderValue(new Dynamic { "one"; "two" }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + new lua.Renderer {}.renderValue(new Foo { a = 1 }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^ reference local Foo_322 +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + } + ["empty documents"] { + new lua.Renderer {}.renderDocument(new Dynamic {}) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + new lua.Renderer {}.renderDocument(new Mapping {}) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + new lua.Renderer {}.renderDocument(Map()) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderDocument(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + } + ["empty values"] { + new lua.Renderer {}.renderValue(new Dynamic {}) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# + new lua.Renderer {}.renderValue(new Mapping {}) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + new lua.Renderer {}.renderValue(new Listing {}) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + new lua.Renderer {}.renderValue(Map()) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map(). + new lua.Renderer {}.renderValue(List()) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + } + ["multiline threshold"] { + new lua.Renderer {}.renderValue(new Dynamic { threshold = 2 }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/threshold. + new lua.Renderer {}.renderValue(new Dynamic { threshold = 2; a = 1 }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/threshold. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + new lua.Renderer { multilineThreshold = 1 }.renderValue(new Dynamic { threshold = 1 }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/multilineThreshold. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/threshold. + new lua.Renderer { multilineThreshold = 3 }.renderValue(new Dynamic { threshold = 3 }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/multilineThreshold. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/threshold. + new lua.Renderer { multilineThreshold = 3 }.renderValue(new Dynamic { threshold = 3; a = 1 }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/multilineThreshold. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/threshold. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. + new lua.Renderer { multilineThreshold = 3 }.renderValue(new Dynamic { threshold = 3; a = 1; b = 2 }) +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/multilineThreshold. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/threshold. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. + } + ["funky table keys"] { + new lua.Renderer {}.renderValue(new Mapping { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + ["a b"] = "space" + ["if"] = "keyword" + [List(1,2)] = "list" +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + [12] = "int" + [12.1] = "float" + [true] = "boolean" + [new Dynamic { a = 1; b = 2 }] = "dynamic" +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/a. +// ^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `tests/renderer.pkl`/b. + }) + } + ["string escapes"] { + new lua.Renderer {}.renderValue(new Listing { +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer# +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.lua 1.1.1 `lua.pkl`/Renderer#renderValue(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + "'" + "\"" + "'\"" + "\nfoo\n" + "foo\nbar" + "\nfoo\nbar\n" + "[[foo\nbar]]" + "[[=[foo\nbar]=]]" + "foo\n\tbar" + "\u{7}\u{8}\u{c}\n\r\t\u{b}" + "\u{1}\u{7f}" + }) + } + } + diff --git a/pkl-pantrysnapshot/pkl.pipe/PklProject b/pkl-pantrysnapshot/pkl.pipe/PklProject new file mode 100755 index 00000000..60ff1a05 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.pipe/PklProject @@ -0,0 +1,33 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Tools for constructing pipelines and one-liners in Pkl, by processing text, JSON, or YAML. + /// + /// Use Pkl's `--expression` (or `-x`) argument to provide a Pkl expression that will be evaluated + /// in the context of the content passed to `stdin`. + /// The Pkl property `pipe` (also aliased as `stdin`) represents the content that was passed to `stdin`. + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 PklProject/package. + version = "1.0.2" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 PklProject/version. + } + + dependencies { +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 PklProject/dependencies. + ["k8s.contrib"] = import("../k8s.contrib/PklProject") + } + diff --git a/pkl-pantrysnapshot/pkl.pipe/examples/github_repos_stars.pkl b/pkl-pantrysnapshot/pkl.pipe/examples/github_repos_stars.pkl new file mode 100755 index 00000000..22af9e7e --- /dev/null +++ b/pkl-pantrysnapshot/pkl.pipe/examples/github_repos_stars.pkl @@ -0,0 +1,44 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// This example shows how to map a Github API response for repos in an org + /// into a list of "reponame: stars". It is the equivalent of the CLI invocation: + /// + /// ``` + /// curl https://api.github.com/orgs/apple/repos | pkl eval json.pkl -x 'pipe.toList().map((r) -> "\(r.name): \(r.stargazers_count)").join("\n")' + /// ``` + module pkl.pipe.examples.github_repos_stars +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/github_repos_stars.pkl`/ + amends "../json.pkl" + + // This does the equivalent of stdin redirection, eg: + // pkl eval json.pkl -x '...' < ./github.json + input = read("./github.json") +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/github_repos_stars.pkl`/input. + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/github_repos_stars.pkl`/output. + // This is equivalent to `pkl eval -x` + text = module.pipe.toList().map((r) -> "\(r.name): \(r.stargazers_count)").join("\n") +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/github_repos_stars.pkl`/text. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `json.pkl`/pipe. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local r_31 +// ^ reference local r_31 +// ^ reference local r_31 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + diff --git a/pkl-pantrysnapshot/pkl.pipe/examples/k8s_deployment_images.pkl b/pkl-pantrysnapshot/pkl.pipe/examples/k8s_deployment_images.pkl new file mode 100755 index 00000000..4d9a2178 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.pipe/examples/k8s_deployment_images.pkl @@ -0,0 +1,37 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// This example shows how to parse a Kubernetes deployment object to get a list of all container images. + /// It is the equivalent of the CLI invocation: + /// + /// ``` + /// pkl eval yaml.pkl -x 'pipe.spec.template.spec.containers.toList().map((c) -> c.image).join("\n")' < examples/k8s_deployment.yaml + /// ``` + module pkl.pipe.examples.k8s_deployment_images +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/k8s_deployment_images.pkl`/ + amends "../yaml.pkl" + + input = read("./k8s_deployment.yaml") +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/k8s_deployment_images.pkl`/input. + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/k8s_deployment_images.pkl`/output. + text = module.pipe.spec.template.spec.containers.toList().map((c) -> c.image).join("\n") +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/k8s_deployment_images.pkl`/text. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/pipe. +// ^ definition local c_28 +// ^ reference local c_28 + } + diff --git a/pkl-pantrysnapshot/pkl.pipe/examples/k8s_name_and_kind.pkl b/pkl-pantrysnapshot/pkl.pipe/examples/k8s_name_and_kind.pkl new file mode 100755 index 00000000..5a8f2035 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.pipe/examples/k8s_name_and_kind.pkl @@ -0,0 +1,41 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// This example shows how to parse a Kubernetes deployment object to get a list of all container images. + /// It is the equivalent of the CLI invocation: + /// + /// ``` + /// pkl eval yaml.pkl -x 'pipe.map((r) -> "\(r.apiVersion).\(r.kind): \(r.metadata.name)").join("\n")' < examples/service_and_pod.yaml + /// ``` + module pkl.pipe.examples.k8s_name_and_kind +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/k8s_name_and_kind.pkl`/ + amends "../yaml.pkl" + + input = read("./k8s_service_and_pod.yaml") +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/k8s_name_and_kind.pkl`/input. + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/k8s_name_and_kind.pkl`/output. + text = module.pipe.map((r) -> "\(r.apiVersion).\(r.kind): \(r.metadata.name)").join("\n") +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `examples/k8s_name_and_kind.pkl`/text. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/pipe. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local r_28 +// ^ reference local r_28 +// ^ reference local r_28 +// ^ reference local r_28 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + diff --git a/pkl-pantrysnapshot/pkl.pipe/json.pkl b/pkl-pantrysnapshot/pkl.pipe/json.pkl new file mode 100755 index 00000000..bb494ee4 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.pipe/json.pkl @@ -0,0 +1,72 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// CLI tool for working with JSON in Pkl, kind of like [jq](https://stedolan.github.io/jq/). + /// + /// Example usage: + /// + /// # Get my IP address + /// curl https://ifconfig.co/json | pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/json.pk -x 'pipe.ip' + /// + /// # Get repos and stars for Github org + /// curl https://api.github.com/orgs/apple/repos | pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/json.pkl -x 'pipe.toList().map((r) -> "\(r.name): \(r.stargazers_count)").join("\n")' + @ModuleInfo { minPklVersion = "0.24.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `json.pkl`/minPklVersion. + module pkl.pipe.json +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `json.pkl`/ + extends "./text.pkl" + + import "pkl:json" + + local parsed = new json.Parser { +// ^^^^^^ definition local parsed_31 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.json`/Parser# + useMapping = read?("prop:useMapping")?.toBoolean() ?? false +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `json.pkl`/useMapping. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toBoolean(). + }.parse(input) +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.json`/Parser#parse(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/input. + + pipe: (List|json.Value)? = if (parsed is Listing) parsed.toList() else parsed +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `json.pkl`/pipe. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.json`/Value# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.json`/Value# +// ^^^^^^ reference local parsed_31 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference local parsed_31 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^^ reference local parsed_31 + stdin: (List|json.Value)? = pipe +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `json.pkl`/stdin. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.json`/Value# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.json`/Value# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `json.pkl`/pipe. + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `json.pkl`/output. + value = pipe +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `json.pkl`/value. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `json.pkl`/pipe. + when (read?("prop:pkl.outputFormat") == null) { + renderer = module.jsonRenderer +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `json.pkl`/renderer. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/jsonRenderer. + } + } + diff --git a/pkl-pantrysnapshot/pkl.pipe/kubeval.pkl b/pkl-pantrysnapshot/pkl.pipe/kubeval.pkl new file mode 100755 index 00000000..38b4aa83 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.pipe/kubeval.pkl @@ -0,0 +1,69 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A Pkl implementation of a Kubernetes manifest validation tool, inspired by + /// [kubeval](https://github.com/instrumenta/kubeval) + /// + /// Example usage: + /// + /// ``` + /// pkl eval <(pkl eval -m package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/kubeval.pkl> < deployment.yaml) + /// # or + /// pkl eval <(pkl eval -p input=deployment.yaml package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/kubeval.pkl) + /// ``` + @ModuleInfo { minPklVersion = "0.24.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `kubeval.pkl`/minPklVersion. + module pkl.pipe.kubeval +//^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `kubeval.pkl`/ + amends "yaml.pkl" + + import "@k8s.contrib/convert.pkl" + + parser { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `kubeval.pkl`/parser. + useMapping = true +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `kubeval.pkl`/useMapping. + } + + input = (read?("prop:input").ifNonNull((it) -> read(it as String)) as Resource?) ?? super.input +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `kubeval.pkl`/input. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#ifNonNull(). +// ^^ definition local it_36 +// ^^ reference local it_36 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/input. + + output = (convert) { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `kubeval.pkl`/output. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib 1.0.3 `convert.pkl`/ + resourcesToConvert = +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `kubeval.pkl`/resourcesToConvert. + let (pipe = module.pipe) +// ^^^^ definition local pipe_40 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/pipe. + if (pipe is List) +// ^^^^ reference local pipe_40 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# + pipe +// ^^^^ reference local pipe_40 + else + List(pipe) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^ reference local pipe_40 + }.output +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. + diff --git a/pkl-pantrysnapshot/pkl.pipe/shellshortcuts.pkl b/pkl-pantrysnapshot/pkl.pipe/shellshortcuts.pkl new file mode 100755 index 00000000..169dea13 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.pipe/shellshortcuts.pkl @@ -0,0 +1,112 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Shell aliases for using Pkl pipe tools. + /// + /// To make using the Pkl pipe tools even easier, this module produces a shell aliases file + /// that is compatible with both bash and zsh. + /// + /// Usage: + /// + /// ``` + /// # First, generate the aliases file + /// pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/shellshortcuts.pkl > ~/.pklpipe + /// + /// # Then add it to your profile or rc file. + /// + /// # For zsh, use: + /// echo 'source ~/.pklpipe' >> ~/.zshrc + /// + /// # For bash with a login shell, use: + /// echo 'source ~/.pklpipe' >> ~/.bash_profile + /// + /// # Then use the shortcuts in commands like: + /// curl https://ifconfig.co/json | pjq 'pipe.ip' + /// ``` + @ModuleInfo { minPklVersion = "0.24.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `shellshortcuts.pkl`/minPklVersion. + module pkl.pipe.shellshortcuts +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `shellshortcuts.pkl`/ + + import "pkl:reflect" + + local modules: Mapping = new { +// ^^^^^^^ definition local modules_43 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module# + ["ptq"] = import("./text.pkl") + ["pjq"] = import("./json.pkl") + ["pyq"] = import("./yaml.pkl") + ["pkubeval"] = import("./kubeval.pkl") + } + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `shellshortcuts.pkl`/output. + text = modules +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `shellshortcuts.pkl`/text. +// ^^^^^^^ reference local modules_43 + .toMap() +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + .entries +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#entries. + .map((el) -> +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^ definition local el_54 + shellFuncForPath( +// ^^^^^^^^^^^^^^^^ reference local shellFuncForPath_62 + el.first, +// ^^ reference local el_54 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#first. + reflect.Module(el.second).uri +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/ +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module(). +// ^^ reference local el_54 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Pair#second. +// ^^^ reference pkl . pkl 0.29.0 `pkl.reflect`/Module#uri. + ) + ).join("\n") + "\n" +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + + /// [shellFuncForPath] renders a function definition which is compatible with + /// both bash and zsh. If a single argument is passed to the function, it will + /// be passed to a Pkl invocation with `--expression`; if no arguments are passed, + /// the Pkl module will be invoked without any arguments. + local function shellFuncForPath(functionName: String, modulePath: String): String = #""" +// ^^^^^^^^^^^^^^^^ definition local shellFuncForPath_62 +// documentation +// > `shellFuncForPath` renders a function definition which is compatible with +// > both bash and zsh. If a single argument is passed to the function, it will +// > be passed to a Pkl invocation with `--expression`; if no arguments are passed, +// > the Pkl module will be invoked without any arguments. +// ^^^^^^^^^^^^ definition local functionName_66 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ definition local modulePath_66 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + function \#(functionName) { +// ^^^^^^^^^^^^ reference local functionName_66 + if [[ -n $1 && "$1" != -* ]]; then + pkl eval \#(modulePath) --expression "$1" "${@:2}" +// ^^^^^^^^^^ reference local modulePath_66 + else + pkl eval \#(modulePath) $@ +// ^^^^^^^^^^ reference local modulePath_66 + fi + } + """# + diff --git a/pkl-pantrysnapshot/pkl.pipe/tests/examples.pkl b/pkl-pantrysnapshot/pkl.pipe/tests/examples.pkl new file mode 100755 index 00000000..a124471f --- /dev/null +++ b/pkl-pantrysnapshot/pkl.pipe/tests/examples.pkl @@ -0,0 +1,38 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.pipe.tests.examples +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `tests/examples.pkl`/ + amends "pkl:test" + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `tests/examples.pkl`/examples. + ["k8s deployment images"] { + import("../examples/k8s_deployment_images.pkl").output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + ["k8s name and kind list"] { + import("../examples/k8s_name_and_kind.pkl").output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + ["github repos and stars"] { + import("../examples/github_repos_stars.pkl").output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + diff --git a/pkl-pantrysnapshot/pkl.pipe/text.pkl b/pkl-pantrysnapshot/pkl.pipe/text.pkl new file mode 100755 index 00000000..3c0fa059 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.pipe/text.pkl @@ -0,0 +1,143 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// Tools for constructing pipelines and one-liners in Pkl. + /// + /// Example usage: + /// + /// ``` + /// # Count characters, like `wc` + /// echo 'fourteen chars' | pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/text.pkl -x 'pipe.length' + /// + /// # Get Pkl filenames as a JSON array (multiple options for JSON-encoding) + /// ls | pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/text.pkl -x 'pipe.split("\n").filter((n) -> n.endsWith("pkl")) |> asJSON' + /// ls | pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/text.pkl -x 'asJson(pipe.split("\n").filter((n) -> n.endsWith("pkl")))' + /// ls | pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/text.pkl -x 'pipe.split("\n").filter((n) -> n.endsWith("pkl")) |> formatted' -f json + /// + /// # Get all filenames grouped by extension + /// ls | pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/text.pkl -x 'asYaml(pipe.split("\n").groupBy((element) -> element.split(".").last))' + /// + /// # Years since the Unix epoch + /// date +"%s" | pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/text.pkl -x 'pipe.trimEnd().toInt().toDuration("s").toUnit("d") / 365' + /// ``` + @ModuleInfo { minPklVersion = "0.24.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/minPklVersion. + open module pkl.pipe.text +//^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/ + + hidden input: Resource(!this.text.trimEnd().isEmpty) = read("file:/dev/stdin") +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/input. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource#text. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#trimEnd(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#isEmpty. + + hidden pipe: String = input.text.trimEnd() +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/pipe. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/input. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Resource#text. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#trimEnd(). + hidden stdin: String = pipe +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/stdin. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/pipe. + + typealias RenderFunc = (Any) -> (String) +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/RenderFunc# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + hidden yamlRenderer: YamlRenderer = new { isStream = true } +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/yamlRenderer. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/YamlRenderer# +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/isStream. + function asYaml(value): String = yamlRenderer.renderValue(value) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asYaml(). +// ^^^^^ definition local value_46 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/yamlRenderer. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/YamlRenderer#renderValue(). +// ^^^^^ reference local value_46 + hidden asYaml: RenderFunc = (value) -> asYaml(value) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asYaml. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/RenderFunc# +// ^^^^^ definition local value_47 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asYaml(). +// ^^^^^ reference local value_47 + hidden toYaml: RenderFunc = asYaml +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/toYaml. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/RenderFunc# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asYaml. + hidden asYAML: RenderFunc = asYaml +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asYAML. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/RenderFunc# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asYaml. + hidden toYAML: RenderFunc = asYaml +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/toYAML. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/RenderFunc# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asYaml. + + hidden jsonRenderer: JsonRenderer = new {} +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/jsonRenderer. +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer# + function asJson(value): String = jsonRenderer.renderValue(value) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asJson(). +// ^^^^^ definition local value_53 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/jsonRenderer. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer#renderValue(). +// ^^^^^ reference local value_53 + hidden asJson: RenderFunc = (value) -> asJson(value) +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asJson. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/RenderFunc# +// ^^^^^ definition local value_54 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asJson(). +// ^^^^^ reference local value_54 + hidden toJson: RenderFunc = asJson +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/toJson. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/RenderFunc# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asJson. + hidden asJSON: RenderFunc = asJson +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asJSON. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/RenderFunc# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asJson. + hidden toJSON: RenderFunc = asJson +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/toJSON. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/RenderFunc# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/asJson. + + hidden formatted = (value) -> output.renderer.renderValue(value) +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/formatted. +// ^^^^^ definition local value_59 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/output. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#renderer. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer#renderValue(). +// ^^^^^ reference local value_59 + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/output. + value = throw(""" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/value. + Error: no expression passed to pkl.pipe.text. Use `--expression` or `-x` to pass a Pkl expression. + + Usage: pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/text.pkl -x + + Example: + echo 'fourteen chars' | pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/text.pkl -x 'pipe.length' + """) + } + diff --git a/pkl-pantrysnapshot/pkl.pipe/yaml.pkl b/pkl-pantrysnapshot/pkl.pipe/yaml.pkl new file mode 100755 index 00000000..281fb3f9 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.pipe/yaml.pkl @@ -0,0 +1,81 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// CLI tool for working with YAML in Pkl, kind of like [yq](https://github.com/mikefarah/yq) or + /// [yq](https://github.com/kislyuk/yq). + /// + /// Example usage: + /// + /// # Get the number of replicas in a Kubernetes deployment YAML file + /// pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/yaml.pkl -x 'pipe.spec.replicas' < deployment.yaml + /// + @ModuleInfo { minPklVersion = "0.24.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/minPklVersion. + module pkl.pipe.yaml +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/ + extends "./text.pkl" + + import "pkl:yaml" + + hidden parser: yaml.Parser = new { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/parser. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Parser# + useMapping = read?("prop:useMapping")?.toBoolean() ?? false +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/useMapping. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toBoolean(). + } + + local yamlDocs: List = parser.parseAll(input) +// ^^^^^^^^ definition local yamlDocs_34 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Value# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/parser. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Parser#parseAll(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/input. + + pipe: (List|yaml.Value)? = +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/pipe. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Value# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Value# + if (yamlDocs.isEmpty) null +// ^^^^^^^^ reference local yamlDocs_34 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + // If there is a single document, set pipe to the value of the single doc, + // rather than force the user to always use `pipe[0]` + else yamlDocs.singleOrNull ?? yamlDocs +// ^^^^^^^^ reference local yamlDocs_34 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#singleOrNull. +// ^^^^^^^^ reference local yamlDocs_34 + stdin: (List|yaml.Value)? = pipe +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/stdin. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Value# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.yaml`/Value# +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/pipe. + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/output. + value = pipe +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/value. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/pipe. + when (read?("prop:pkl.outputFormat") == null) { + renderer = module.yamlRenderer +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `yaml.pkl`/renderer. +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe 1.0.2 `text.pkl`/yamlRenderer. + } + } + diff --git a/pkl-pantrysnapshot/pkl.table/PklProject b/pkl-pantrysnapshot/pkl.table/PklProject new file mode 100755 index 00000000..0ca327cc --- /dev/null +++ b/pkl-pantrysnapshot/pkl.table/PklProject @@ -0,0 +1,26 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// [TableRenderer] generates pretty human-readable and markdown-compatible tables! + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 PklProject/package. + version = "1.1.0" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 PklProject/version. + description = "Generates pretty human-readable, markdown-compatible, and HTML tables." +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 PklProject/description. + } + diff --git a/pkl-pantrysnapshot/pkl.table/table.pkl b/pkl-pantrysnapshot/pkl.table/table.pkl new file mode 100755 index 00000000..107b7721 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.table/table.pkl @@ -0,0 +1,778 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// [TableRenderer] generates pretty tables! + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/minPklVersion. + module pkl.table.table +//^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ + + import "pkl:math" + + typealias ColumnKey = String +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ColumnKey# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + typealias ListLike = List|Listing|Dynamic(toMap().isEmpty) +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ListLike# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed#toMap(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#isEmpty. + const local listLikeDescription = "`List`s, `Listing`s, or `Dynamic`s with only elements" +// ^^^^^^^^^^^^^^^^^^^ definition local listLikeDescription_24 + + typealias HorizontalPosition = "left"|"inner"|"right" +// ^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/HorizontalPosition# + typealias VerticalPosition = "top"|"inner"|"bottom" +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/VerticalPosition# + typealias Alignment = "left"|"right" +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Alignment# + + const function Column(_key: String): Column = new { key = _key } +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^ definition local _key_30 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column# +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/key. +// ^^^^ reference local _key_30 + class Column { +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column# + /// The key used to extract property values from rows + key: ColumnKey +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. +// documentation +// > The key used to extract property values from rows +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ColumnKey# + + /// The column header title + title: String = key +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#title. +// documentation +// > The column header title +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. + + /// The direction to align and pad column contents within a cell + align: Alignment = "left" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#align. +// documentation +// > The direction to align and pad column contents within a cell +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Alignment# + } + + /// Used to provide fully custom content for an entire table row + /// One possible usage is to express colspan in HTML tables + open class RowDirective { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/RowDirective# +// documentation +// > Used to provide fully custom content for an entire table row +// > One possible usage is to express colspan in HTML tables + content: String +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/RowDirective#content. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + function render(style: TableStyle): String = content +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/RowDirective#render(). +// ^^^^^ definition local style_47 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/RowDirective#content. + } + + /// Style options used to draw the table + /// Default values produce a table consisting of simple ASCII characters + open class TableStyle { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle# +// documentation +// > Style options used to draw the table +// > Default values produce a table consisting of simple ASCII characters + /// Placeholder to use in place of null property values + nullPlaceholder: String = "null" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#nullPlaceholder. +// documentation +// > Placeholder to use in place of null property values +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Include a header in the table + includeHeader: Boolean = true +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#includeHeader. +// documentation +// > Include a header in the table +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + + /// Default character to use for horizontal rules + defaultHorizontal: String(!fixedWidth || length == 1) = "-" +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultHorizontal. +// documentation +// > Default character to use for horizontal rules +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#fixedWidth. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + + /// Indicates whether or not the table is expected to produce fixed-width output + /// Disabling this enables styles to produce markup languages like HTML + fixedWidth = true +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#fixedWidth. +// documentation +// > Indicates whether or not the table is expected to produce fixed-width output +// > Disabling this enables styles to produce markup languages like HTML + + /// Characters to use for specific horizontal rules + horizontals: Mapping = new { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#horizontals. +// documentation +// > Characters to use for specific horizontal rules +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/VerticalPosition# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#fixedWidth. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + ["top"] = defaultHorizontal +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultHorizontal. + ["inner"] = defaultHorizontal +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultHorizontal. + ["bottom"] = defaultHorizontal +// ^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultHorizontal. + } + + /// Default character to use for vertical rules + defaultVertical: String(!fixedWidth || length == 1) = "|" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultVertical. +// documentation +// > Default character to use for vertical rules +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#fixedWidth. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + + /// Characters to use for specific horizontal rules + verticals: Mapping = new { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#verticals. +// documentation +// > Characters to use for specific horizontal rules +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/HorizontalPosition# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#fixedWidth. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + ["left"] = defaultVertical +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultVertical. + ["inner"] = defaultVertical +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultVertical. + ["right"] = defaultVertical +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultVertical. + } + + /// Characters to use for specific vertical rules in the header + headerVerticals: Mapping = verticals +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#headerVerticals. +// documentation +// > Characters to use for specific vertical rules in the header +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/HorizontalPosition# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#fixedWidth. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#verticals. + + /// Default character to use for corners + defaultCorner: String(!fixedWidth || length == 1) = "+" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultCorner. +// documentation +// > Default character to use for corners +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#fixedWidth. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + + /// Characters to use for specific corners + corners: Mapping> = new { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#corners. +// documentation +// > Characters to use for specific corners +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/HorizontalPosition# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/VerticalPosition# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#fixedWidth. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + ["left"] { + ["top"] = defaultCorner +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultCorner. + ["inner"] = defaultCorner +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultCorner. + ["bottom"] = defaultCorner +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultCorner. + } + ["inner"] { + ["top"] = defaultCorner +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultCorner. + ["inner"] = defaultCorner +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultCorner. + ["bottom"] = defaultCorner +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultCorner. + } + ["right"] { + ["top"] = defaultCorner +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultCorner. + ["inner"] = defaultCorner +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultCorner. + ["bottom"] = defaultCorner +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#defaultCorner. + } + } + } + + /// Style options specific to HTML tables + /// Default values produce a table with two-space indentation + open class TableStyleHTML extends TableStyle { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML# +// documentation +// > Style options specific to HTML tables +// > Default values produce a table with two-space indentation +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle# + /// Controls which character(s) are used for one indentation level + indent: String = " " +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// documentation +// > Controls which character(s) are used for one indentation level +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + /// Indent controls the baseline indent level applied to every line + baseIndent: String = "" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// documentation +// > Indent controls the baseline indent level applied to every line +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + local _style = this +// ^^^^^^ definition local _style_118 + + fixedWidth = false +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#fixedWidth. +// documentation +// > Indicates whether or not the table is expected to produce fixed-width output +// > Disabling this enables styles to produce markup languages like HTML + defaultCorner = "" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#defaultCorner. +// documentation +// > Default character to use for corners + horizontals { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#horizontals. +// documentation +// > Characters to use for specific horizontal rules + ["top"] = "\(baseIndent)\n\(baseIndent)\(indent)<\(if (_style.includeHeader) "thead" else "tbody")>" +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^ reference local _style_118 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#includeHeader. + ["inner"] = "\(baseIndent)\(indent)\n\(baseIndent)\(indent)" +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. + ["bottom"] = "\(baseIndent)\(indent)\n\(baseIndent)
" +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. + } + verticals { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#verticals. +// documentation +// > Characters to use for specific horizontal rules + ["left"] = "\(baseIndent)\(indent.repeat(2))\n\(baseIndent)\(indent.repeat(3))" +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). + ["inner"] = "\n\(baseIndent)\(indent.repeat(3))" +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). + ["right"] = "\n\(baseIndent)\(indent.repeat(2))" +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). + } + headerVerticals { +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#headerVerticals. +// documentation +// > Characters to use for specific vertical rules in the header + ["left"] = "\(baseIndent)\(indent.repeat(2))\n\(baseIndent)\(indent.repeat(3))" +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). + ["inner"] = "\n\(baseIndent)\(indent.repeat(3))" +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). + ["right"] = "\n\(baseIndent)\(indent.repeat(2))" +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#baseIndent. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). + } + } + + local class InterimTable { +// ^^^^^^^^^^^^ definition local InterimTable_139 + + style: TableStyle +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle# + converters: Mapping Any> +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#converters. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + columns: Listing +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columns. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column# + rows: List +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#rows. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# + + columnWidths: Mapping = new { +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columnWidths. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ColumnKey# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + for (column in columns) { +// ^^^^^^ definition local column_148 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columns. + [column.key] = math.max( +// ^^^^^^ reference local column_148 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^ reference pkl . pkl 0.29.0 `pkl.math`/max(). + column.title.length, +// ^^^^^^ reference local column_148 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#title. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + renderedCells.fold(0, (acc, it) -> +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderedCells. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#fold(). +// ^^^ definition local acc_151 +// ^^ definition local it_151 + math.max(acc, it.getOrNull(column.key)?.length ?? 0) +// ^^^^ reference pkl . pkl 0.29.0 `pkl.math`/ +// ^^^ reference pkl . pkl 0.29.0 `pkl.math`/max(). +// ^^^ reference local acc_151 +// ^^ reference local it_151 +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^^ reference local column_148 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#length. + ) + ) as UInt +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/UInt# + } + } + + renderedCells: Listing<*Mapping | RowDirective> = new { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderedCells. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ColumnKey# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/RowDirective# + for (row in rows) { +// ^^^ definition local row_159 +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#rows. + when (row is RowDirective) { +// ^^^ reference local row_159 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/RowDirective# + row +// ^^^ reference local row_159 + } else { + new { + for (column in columns) { +// ^^^^^^ definition local column_164 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columns. + [column.key] = renderCell(column.key, row.getPropertyOrNull(column.key)) +// ^^^^^^ reference local column_164 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderCell(). +// ^^^^^^ reference local column_164 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. +// ^^^ reference local row_159 +// ^^^^^^ reference local column_164 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. + } + } + } + } + } + + rendered = new Listing { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#rendered. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + when (style.horizontals["top"] != null) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#horizontals. + renderHorizontalRule("top") +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderHorizontalRule(). + } + when (style.includeHeader) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#includeHeader. + renderRow(columns.toList().toMap((col) -> col.key, (col) -> col.title), true) +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderRow(). +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columns. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#toMap(). +// ^^^ definition local col_177 +// ^^^ reference local col_177 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. +// ^^^ definition local col_177 +// ^^^ reference local col_177 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#title. + when (style.horizontals["inner"] != null) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#horizontals. + renderHorizontalRule("inner") +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderHorizontalRule(). + } + } + for (row in renderedCells) { +// ^^^ definition local row_182 +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderedCells. + when (row is RowDirective) { +// ^^^ reference local row_182 +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/RowDirective# + row.render(style) +// ^^^ reference local row_182 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/RowDirective#render(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. + } else { + renderRow(row.toMap(), false) +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderRow(). +// ^^^ reference local row_182 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + } + } + when (style.horizontals["bottom"] != null) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#horizontals. + renderHorizontalRule("bottom") +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderHorizontalRule(). + } + }.join("\n") + "\n" +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + + function renderCell(col: String, value: Any): String = +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderCell(). +// ^^^ definition local col_194 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^ definition local value_194 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + (converters.getOrNull(col)?.apply(value)?.toString()) ?? +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#converters. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^ reference local col_194 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^ reference local value_194 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#toString(). + (converters.getOrNull(value.getClass())?.apply(value)?.toString()) ?? +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#converters. +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#getOrNull(). +// ^^^^^ reference local value_194 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^^^ reference local value_194 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#toString(). + value?.toString() ?? +// ^^^^^ reference local value_194 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#toString(). + style.nullPlaceholder +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#nullPlaceholder. + + function renderRow(renderedCells: Map, inHeader: Boolean) = new Listing { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderRow(). +// ^^^^^^^^^^^^^ definition local renderedCells_200 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ColumnKey# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^ definition local inHeader_200 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + local verticals = if (inHeader) style.headerVerticals else style.verticals +// ^^^^^^^^^ definition local verticals_201 +// ^^^^^^^^ reference local inHeader_200 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#headerVerticals. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#verticals. + verticals["left"] ?? "" +// ^^^^^^^^^ reference local verticals_201 + for (i, col in columns) { +// ^ definition local i_203 +// ^^^ definition local col_203 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columns. + when (style.fixedWidth) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#fixedWidth. + " " + if (col.align == "left") +// ^^^ reference local col_203 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#align. + renderedCells[col.key].padEnd(columnWidths[col.key], " ") +// ^^^^^^^^^^^^^ reference local renderedCells_200 +// ^^^ reference local col_203 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padEnd(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columnWidths. +// ^^^ reference local col_203 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. + else if (col.align == "right") +// ^^^ reference local col_203 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#align. + renderedCells[col.key].padStart(columnWidths[col.key], " ") +// ^^^^^^^^^^^^^ reference local renderedCells_200 +// ^^^ reference local col_203 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#padStart(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columnWidths. +// ^^^ reference local col_203 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. + else "" + " " + } else { + renderedCells[col.key] +// ^^^^^^^^^^^^^ reference local renderedCells_200 +// ^^^ reference local col_203 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. + } + verticals[if (i == columns.length - 1) "right" else "inner"] ?? "" +// ^^^^^^^^^ reference local verticals_201 +// ^ reference local i_203 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columns. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#length. + } + }.join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + + function renderHorizontalRule(verticalPosition: VerticalPosition): String = new Listing { +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#renderHorizontalRule(). +// ^^^^^^^^^^^^^^^^ definition local verticalPosition_219 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/VerticalPosition# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + style.corners["left"][verticalPosition] +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#corners. +// ^^^^^^^^^^^^^^^^ reference local verticalPosition_219 + when (style.fixedWidth) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#fixedWidth. + for (i, col in columns) { +// ^ definition local i_222 +// ^^^ definition local col_222 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columns. + style.horizontals[verticalPosition].repeat(columnWidths[col.key] + 2) +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#horizontals. +// ^^^^^^^^^^^^^^^^ reference local verticalPosition_219 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columnWidths. +// ^^^ reference local col_222 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column#key. + style.corners[if (i == columns.length - 1) "right" else "inner"][verticalPosition] +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#corners. +// ^ reference local i_222 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#columns. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#length. +// ^^^^^^^^^^^^^^^^ reference local verticalPosition_219 + } + } else { + style.horizontals[verticalPosition] +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#style. +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle#horizontals. +// ^^^^^^^^^^^^^^^^ reference local verticalPosition_219 + } + }.join("") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#join(). + } + + /// [pkl.ValueRenderer] subclass used to render pretty-printed tables + class TableRenderer extends ValueRenderer { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer# +// documentation +// > `pkl.ValueRenderer` subclass used to render pretty-printed tables +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer# + /// Style to use for table rendering + style: TableStyle +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#style. +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle# + + /// Listing of properties that should be rendered as table columns + columns: Listing(!isEmpty || throw("TableRenderer must be configured to render at least one column")) +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#columns. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#isEmpty. + + local self = this +// ^^^^ definition local self_240 + + /// Renders [value] as a pretty-printed table. + function renderDocument(value: Any): String = new InterimTable { +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#renderDocument(). +// documentation +// > Renders [`value`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.table/table.pkl#L243,C27) as a pretty-printed table. +// ^^^^^ definition local value_243 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^^^^^^ reference local InterimTable_139 + columns { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#columns. + for (col in self.columns) { +// ^^^ definition local col_245 +// ^^^^ reference local self_240 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#columns. + if (col is Column) col else Column(col) +// ^^^ reference local col_245 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column# +// ^^^ reference local col_245 +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^ reference local col_245 + } + } + rows = +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#rows. + if (value is ListLike?) value.toList() +// ^^^^^ reference local value_243 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ListLike# +// ^^^^^ reference local value_243 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). + else throw("Only \(listLikeDescription) values can be rendered as a table. Instead, found a \(value.getClass()).\n\nValue:\n\(value)") +// ^^^^^^^^^^^^^^^^^^^ reference local listLikeDescription_24 +// ^^^^^ reference local value_243 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). +// ^^^^^ reference local value_243 + style = self.style +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#style. +// ^^^^ reference local self_240 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#style. + converters = self.converters +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#converters. +// ^^^^ reference local self_240 +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer#converters. + }.rendered +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/InterimTable#rendered. + + /// Unsupported. [renderCell] is used instead as the column name must be known to look up the relevant converter + function renderValue(_): String = throw("TableRenderer can only render documents, not values") +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#renderValue(). +// documentation +// > Unsupported. `renderCell` is used instead as the column name must be known to look up the relevant converter +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// [TableStyle] using unicode box drawing characters (light variants) + const boxDrawingLightStyle: TableStyle = new { +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/boxDrawingLightStyle. +// documentation +// > [`TableStyle`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.table/table.pkl#L52,C12) using unicode box drawing characters (light variants) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle# + defaultHorizontal = "─" +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/defaultHorizontal. + defaultVertical = "│" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/defaultVertical. + corners { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/corners. + ["left"] { + ["top"] = "┌" + ["inner"] = "├" + ["bottom"] = "└" + } + ["inner"] { + ["top"] = "┬" + ["inner"] = "┼" + ["bottom"] = "┴" + } + ["right"] { + ["top"] = "┐" + ["inner"] = "┤" + ["bottom"] = "┘" + } + } + } + + /// [TableStyle] using unicode box drawing characters (heavy variants) + const boxDrawingHeavyStyle: TableStyle = new { +// ^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/boxDrawingHeavyStyle. +// documentation +// > [`TableStyle`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.table/table.pkl#L52,C12) using unicode box drawing characters (heavy variants) +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle# + defaultHorizontal = "━" +// ^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/defaultHorizontal. + defaultVertical = "┃" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/defaultVertical. + corners { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/corners. + ["left"] { + ["top"] = "┏" + ["inner"] = "┣" + ["bottom"] = "┗" + } + ["inner"] { + ["top"] = "┳" + ["inner"] = "╋" + ["bottom"] = "┻" + } + ["right"] { + ["top"] = "┓" + ["inner"] = "┫" + ["bottom"] = "┛" + } + } + } + + /// [TableStyle] that renders Markdown-compatible tables + const markdownStyle: TableStyle = new { +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/markdownStyle. +// documentation +// > [`TableStyle`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.table/table.pkl#L52,C12) that renders Markdown-compatible tables +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyle# + defaultCorner = "|" +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/defaultCorner. + horizontals { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/horizontals. + ["top"] = null + ["bottom"] = null + } + } + + /// [TableStyle] that renders HTML tables + const htmlStyle: TableStyleHTML = new {} +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/htmlStyle. +// documentation +// > [`TableStyle`](file:///Users/thomas/src/github.com/apple/pkl-pantry/packages/pkl.table/table.pkl#L52,C12) that renders HTML tables +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML# + diff --git a/pkl-pantrysnapshot/pkl.table/tests/table.pkl b/pkl-pantrysnapshot/pkl.table/tests/table.pkl new file mode 100755 index 00000000..035302e0 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.table/tests/table.pkl @@ -0,0 +1,254 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.table.tests.table +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/ + + amends "pkl:test" + + import "../table.pkl" + + local data = new Listing { +// ^^^^ definition local data_22 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + new { alpha = "123"; beta = 123; gamma = 123.h; delta = List("1", "2", "3") } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/alpha. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/beta. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/gamma. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#h. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/delta. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + new { alpha = "456"; beta = 456; gamma = 456.h; delta = List("4", "5", "6") } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/alpha. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/beta. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/gamma. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#h. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/delta. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + new { alpha = "789loooooong"; beta = 789; gamma = 789.h; delta = List("7", "8", "9") } +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/alpha. +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/beta. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/gamma. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#h. +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/delta. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). + } + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/examples. + ["simple"] { + new table.TableRenderer { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer# + columns { "alpha"; "beta"; "gamma" } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/columns. + }.renderDocument(data) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#renderDocument(). +// ^^^^ reference local data_22 + } + ["fancy column"] { + new table.TableRenderer { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer# + style { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/style. + nullPlaceholder = "" +// ^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/nullPlaceholder. + } + columns { +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/columns. + (table.Column("alpha")) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). + title = "a" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/title. + align = "right" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/align. + } + (table.Column("beta")) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). + title = "b" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/title. + } + (table.Column("gamma")) { +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). + title = "c" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/title. + } + "unknown" + } + }.renderDocument(data) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#renderDocument(). +// ^^^^ reference local data_22 + } + ["row directive"] { + new table.TableRenderer { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer# + style = table.htmlStyle +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/style. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/htmlStyle. + columns { table.Column("alpha"); table.Column("beta"); table.Column("gamma") } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/columns. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). + }.renderDocument((data) { +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#renderDocument(). +// ^^^^ reference local data_22 + new table.RowDirective { content = "\(table.htmlStyle.indent.repeat(2))this is a colspan" } +// ^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/RowDirective# +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/content. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/htmlStyle. +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableStyleHTML#indent. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#repeat(). + }) + } + ["coverter"] { + new table.TableRenderer { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer# + columns { table.Column("alpha"); table.Column("beta"); table.Column("gamma"); table.Column("delta") } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/columns. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/converters. + [Duration] = (it) -> it.toUnit("s") +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# +// ^^ definition local it_66 +// ^^ reference local it_66 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#toUnit(). + ["delta"] = (it) -> it.join(",") +// ^^ definition local it_67 +// ^^ reference local it_67 + } + }.renderDocument(data) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#renderDocument(). +// ^^^^ reference local data_22 + } + ["boxDrawingLight"] { + new table.TableRenderer { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer# + style = table.boxDrawingLightStyle +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/style. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/boxDrawingLightStyle. + columns { table.Column("alpha"); table.Column("beta"); table.Column("gamma") } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/columns. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). + }.renderDocument(data) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#renderDocument(). +// ^^^^ reference local data_22 + } + ["boxDrawingHeavy"] { + new table.TableRenderer { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer# + style = table.boxDrawingHeavyStyle +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/style. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/boxDrawingHeavyStyle. + columns { table.Column("alpha"); table.Column("beta"); table.Column("gamma") } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/columns. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). + }.renderDocument(data) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#renderDocument(). +// ^^^^ reference local data_22 + } + ["markdown"] { + new table.TableRenderer { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer# + style = table.markdownStyle +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/style. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/markdownStyle. + columns { table.Column("alpha"); table.Column("beta"); table.Column("gamma") } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/columns. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). + }.renderDocument(data) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#renderDocument(). +// ^^^^ reference local data_22 + } + ["html"] { + new table.TableRenderer { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer# + style = table.htmlStyle +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/style. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/htmlStyle. + columns { table.Column("alpha"); table.Column("beta"); table.Column("gamma") } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/columns. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). + }.renderDocument(data) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#renderDocument(). +// ^^^^ reference local data_22 + } + ["html with custom indent and no header"] { + new table.TableRenderer { +// ^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer# + style = (table.htmlStyle) { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/style. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/htmlStyle. + baseIndent = "indent:" +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/baseIndent. + indent = "\t" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/indent. + includeHeader = false +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/includeHeader. + } + columns { table.Column("alpha"); table.Column("beta"); table.Column("gamma") } +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `tests/table.pkl`/columns. +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/ +// ^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/Column(). + }.renderDocument(data) +// ^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.table 1.1.0 `table.pkl`/TableRenderer#renderDocument(). +// ^^^^ reference local data_22 + } + } + diff --git a/pkl-pantrysnapshot/pkl.toml/PklProject b/pkl-pantrysnapshot/pkl.toml/PklProject new file mode 100755 index 00000000..e7d1d440 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.toml/PklProject @@ -0,0 +1,24 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A [TOML](https://toml.io/en/) [Renderer]. + amends "../basePklProject.pkl" + + package { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 PklProject/package. + version = "1.0.2" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 PklProject/version. + } + diff --git a/pkl-pantrysnapshot/pkl.toml/examples/basic.pkl b/pkl-pantrysnapshot/pkl.toml/examples/basic.pkl new file mode 100755 index 00000000..52590fdf --- /dev/null +++ b/pkl-pantrysnapshot/pkl.toml/examples/basic.pkl @@ -0,0 +1,206 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.toml.examples.basic +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/ + + import "../toml.pkl" + + title = "TOML Example" +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/title. + + owner { +//^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/owner. + name = "Tom Preston-Werner" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/name. + organization = "Github" +// ^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/organization. + bio = """ +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/bio. + GitHub Cofounder & CEO + Likes tater tots and beer + """ + dob = new toml.DateTime { value = "1979-05-27T07:32:00Z" } +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/dob. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/DateTime# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/value. + } + + database { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/database. + server = "192.168.1.1" +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/server. + ports { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/ports. + 8001 + 8001 + 8002 + } + connection_max = 5000 +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/connection_max. + enabled = true +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/enabled. + datasource_properties = new Mapping { +// ^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/datasource_properties. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + ["driverClassName"] = "com.mysql.jdbc.Driver" + ["initialSize"] = "5" + } + empty_properties = new Mapping {} +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/empty_properties. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + optional_config: Mapping? = null +//^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/optional_config. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + + servers { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/servers. + alpha { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/alpha. + ip = "10.0.0.1" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/ip. + dc = "eqdc10" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/dc. + } + beta { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/beta. + ip = "10.0.0.2" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/ip. + dc = "eqdc10" +// ^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/dc. + country = "中国" +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/country. + } + } + + clients { +//^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/clients. + data { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/data. + new { + "gamma" + "delta" + } + new { + 1 + 2 + } + } + hosts { +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/hosts. + "alpha" + "omega" + } + } + + + products { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/products. + new { + name = "Hammer Bro" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/name. + sku = 738594937 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/sku. + } + new {} + new { + name = "Nail" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/name. + sku = 284758393 +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/sku. + color = "gray" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/color. + `1-1` = "〇😀" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/1-1. + } + } + + fruits { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/fruits. + new { + name = "apple" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/name. + physical { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/physical. + color = "red" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/color. + shape = "round" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/shape. + } + varieties { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/varieties. + new { name = "red delicious" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/name. + new { name = "granny smith" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/name. + } + } + new { + name = "banana" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/name. + varieties { +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/varieties. + new { name = "plantain" } +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/name. + } + } + } + + contributors { +//^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/contributors. + "Foo Bar " + new { + name = "Baz Qux" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/name. + email = "bazqux@example.com" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/email. + url = "https://example.com/bazqux" +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/url. + } + } + + dog { +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/dog. + `tater.man` { +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/`tater.man`. + type { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/type. + name = "pug" +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/name. + } + age = NaN +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/age. +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/NaN. + maxAge = Infinity +// ^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/maxAge. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Infinity. + } + } + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/output. + renderer = new toml.Renderer {} +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/basic.pkl`/renderer. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Renderer# + } + diff --git a/pkl-pantrysnapshot/pkl.toml/examples/converters.pkl b/pkl-pantrysnapshot/pkl.toml/examples/converters.pkl new file mode 100755 index 00000000..1c3b1227 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.toml/examples/converters.pkl @@ -0,0 +1,88 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.toml.examples.converters +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/ + + import "../toml.pkl" + + class Dog { +// ^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/Dog# + breed: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/Dog#breed. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + sleepTime: Duration +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/Dog#sleepTime. +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# + } + + dogs { +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/dogs. + new Dog { +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/Dog# + breed = "Golden Retreiver" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/breed. + sleepTime = 12.h +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/sleepTime. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#h. + } + new Dog { +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/Dog# + breed = "GERMAN SHEPHERD" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/breed. + sleepTime = 10.h +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/sleepTime. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#h. + } + new Dog { +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/Dog# + breed = "greyhound" +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/breed. + sleepTime = 18.h +// ^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/sleepTime. +// ^ reference pkl . pkl 0.29.0 `pkl.base`/Int#h. + } + } + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/output. + renderer = new toml.Renderer { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/renderer. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Renderer# + converters { +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/converters. + [Dog] = (dog: Dog) -> (dog) { +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/Dog# +// ^^^ definition local dog_43 +// ^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/Dog# +// ^^^ reference local dog_43 + breed = dog.breed.toLowerCase() +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/breed. +// ^^^ reference local dog_43 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/converters.pkl`/Dog#breed. +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#toLowerCase(). + } + [Duration] = (dur: Duration) -> "\(dur.value)\(dur.unit)" +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# +// ^^^ definition local dur_46 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration# +// ^^^ reference local dur_46 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#value. +// ^^^ reference local dur_46 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Duration#unit. + } + } + } + diff --git a/pkl-pantrysnapshot/pkl.toml/examples/dates.pkl b/pkl-pantrysnapshot/pkl.toml/examples/dates.pkl new file mode 100755 index 00000000..3ddc55d0 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.toml/examples/dates.pkl @@ -0,0 +1,71 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.toml.examples.dates +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/ + + import "../toml.pkl" + + // Offset Date-Time + odt1 = new toml.DateTime { value = "1979-05-27T07:32:00Z" } +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/odt1. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/DateTime# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/value. + odt2 = new toml.DateTime { value = "1979-05-27T00:32:00-07:00" } +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/odt2. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/DateTime# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/value. + odt3 = new toml.DateTime { value = "1979-05-27T00:32:00.999999-07:00" } +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/odt3. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/DateTime# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/value. + odt4 = new toml.DateTime { value = "1979-05-27 07:32:00Z" } +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/odt4. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/DateTime# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/value. + + // Local Date-Time + ldt1 = new toml.DateTime { value = "1979-05-27T07:32:00" } +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/ldt1. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/DateTime# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/value. + ldt2 = new toml.DateTime { value = "1979-05-27T00:32:00.999999" } +//^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/ldt2. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/DateTime# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/value. + + // Local Date + ld1 = new toml.Date { value = "1979-05-27" } +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/ld1. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Date# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/value. + + // Local Time + lt1 = new toml.Time { value = "07:32:00" } +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/lt1. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Time# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/value. + lt2 = new toml.Time { value = "00:32:00.999999" } +//^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/lt2. +// ^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Time# +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/value. + + output { +//^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/output. + renderer = new toml.Renderer {} +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `examples/dates.pkl`/renderer. +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Renderer# + } + diff --git a/pkl-pantrysnapshot/pkl.toml/tests/toml.pkl b/pkl-pantrysnapshot/pkl.toml/tests/toml.pkl new file mode 100755 index 00000000..5263b671 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.toml/tests/toml.pkl @@ -0,0 +1,39 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + module pkl.toml.tests.toml +//^^^^^^^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `tests/toml.pkl`/ + + amends "pkl:test" + + examples { +//^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `tests/toml.pkl`/examples. + ["basic.pkl"] { + import("../examples/basic.pkl").output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + ["converters.pkl"] { + import("../examples/converters.pkl").output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + ["dates.pkl"] { + import("../examples/dates.pkl").output.text +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Module#output. +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/FileOutput#text. + } + } + diff --git a/pkl-pantrysnapshot/pkl.toml/toml.pkl b/pkl-pantrysnapshot/pkl.toml/toml.pkl new file mode 100755 index 00000000..46909f07 --- /dev/null +++ b/pkl-pantrysnapshot/pkl.toml/toml.pkl @@ -0,0 +1,649 @@ + //===----------------------------------------------------------------------===// + // Copyright © 2024 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. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + //===----------------------------------------------------------------------===// + /// A renderer for [TOML](https://toml.io) configuration files. + /// + /// Basic usage: + /// ``` + /// import "package://pkg.pkl-lang.org/pantry/pkl.toml@1.0.0" + /// + /// output { + /// renderer = new toml.Renderer {} + /// } + /// ``` + /// + /// To render TOML dates and times, use [Date], [Time], and [DateTime]. + @ModuleInfo { minPklVersion = "0.25.0" } +// ^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ModuleInfo# +// ^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/minPklVersion. + module pkl.toml.toml +//^^^^^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/ + + abstract class AbstractDateTime { +// ^^^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/AbstractDateTime# + value: String +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/AbstractDateTime#value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + } + + /// A TOML [Local Date](https://toml.io/en/v1.0.0#local-date) value. + class Date extends AbstractDateTime { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Date# +// documentation +// > A TOML [Local Date](https://toml.io/en/v1.0.0#local-date) value. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/AbstractDateTime# + value: String(matches(Regex(#"(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])"#))) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Date#value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + } + + /// A TOML [Local Time](https://toml.io/en/v1.0.0#local-time) value. + class Time extends AbstractDateTime { +// ^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Time# +// documentation +// > A TOML [Local Time](https://toml.io/en/v1.0.0#local-time) value. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/AbstractDateTime# + value: String(matches(Regex(#"([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?"#))) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Time#value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + } + + /// A TOML [Offset Date-Time](https://toml.io/en/v1.0.0#offset-date-time) + /// or [Local Date-Time](https://toml.io/en/v1.0.0#local-date-time) value. + class DateTime extends AbstractDateTime { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/DateTime# +// documentation +// > A TOML [Offset Date-Time](https://toml.io/en/v1.0.0#offset-date-time) +// > or [Local Date-Time](https://toml.io/en/v1.0.0#local-date-time) value. +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/AbstractDateTime# + value: String(matches(Regex(#"(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])[T ]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|[+-]([01][0-9]|2[0-3]):([0-5][0-9]))?"#))) +// ^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/DateTime#value. +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + } + + /// Renders values as TOML. + class Renderer extends ValueRenderer { +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Renderer# +// documentation +// > Renders values as TOML. +// ^^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/ValueRenderer# + /// Value converters to apply before values are rendered. + /// + /// For further information see [PcfRenderer.converters]. + /// For path converters, only "*" is supported. + converters: Mapping Any> +// ^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Renderer#converters. +// documentation +// > Value converters to apply before values are rendered. +// > +// > For further information see [`PcfRenderer.converters`](pkl-lsp://stdlib/base.pkl#L308,C3). +// > For path converters, only "*" is supported. +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Class# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + + function renderValue(value: Any) = +// ^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Renderer#renderValue(). +// documentation +// > Renders [`value`](pkl-lsp://stdlib/base.pkl#L323,C33). +// ^^^^^ definition local value_59 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + let (_value = getBasicValue(value, false)) +// ^^^^^^ definition local _value_60 +// ^^^^^^^^^^^^^ reference local getBasicValue_86 +// ^^^^^ reference local value_59 + doRenderValue(_value, List()).trim() +// ^^^^^^^^^^^^^ reference local doRenderValue_104 +// ^^^^^^ reference local _value_60 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#trim(). + + function renderDocument(value: Any) = +// ^^^^^^^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Renderer#renderDocument(). +// documentation +// > Renders [`value`](pkl-lsp://stdlib/base.pkl#L320,C36) as a complete document. +// > +// > Some renderers impose restrictions on which types of values can be rendered as document. +// > +// > A typical implementation of this method renders a document header/footer +// > and otherwise delegates to [`renderValue()`](pkl-lsp://stdlib/base.pkl#L323,C3). +// ^^^^^ definition local value_63 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + if (!isTableLike(value)) +// ^^^^^^^^^^^ reference local isTableLike_113 +// ^^^^^ reference local value_63 + throw(""" + Invalid input: TOML can only render object-types at the root level. Received: \(value) +// ^^^^^ reference local value_63 + """) + else + renderValue(value) +// ^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Renderer#renderValue(). +// ^^^^^ reference local value_63 + + local jsonRenderer = new JsonRenderer {} +// ^^^^^^^^^^^^ definition local jsonRenderer_71 +// ^^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer# + + local function getConvertersForValue(value: Any): List<(Any) -> unknown> = new Listing { +// ^^^^^^^^^^^^^^^^^^^^^ definition local getConvertersForValue_73 +// ^^^^^ definition local value_73 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + when (convertersMap.containsKey(value.getClass())) { +// ^^^^^^^^^^^^^ reference local convertersMap_132 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#containsKey(). +// ^^^^^ reference local value_73 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + convertersMap[value.getClass()] +// ^^^^^^^^^^^^^ reference local convertersMap_132 +// ^^^^^ reference local value_73 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any#getClass(). + } + when (convertersMap.containsKey("*")) { +// ^^^^^^^^^^^^^ reference local convertersMap_132 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#containsKey(). + convertersMap["*"] +// ^^^^^^^^^^^^^ reference local convertersMap_132 + } + }.toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + + local function applyConverters(value: Any) = +// ^^^^^^^^^^^^^^^ definition local applyConverters_82 +// ^^^^^ definition local value_82 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + let (converters = getConvertersForValue(value)) +// ^^^^^^^^^^ definition local converters_83 +// ^^^^^^^^^^^^^^^^^^^^^ reference local getConvertersForValue_73 +// ^^^^^ reference local value_82 + converters.fold(value, (acc, converter) -> converter.apply(acc)) +// ^^^^^^^^^^ reference local converters_83 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#fold(). +// ^^^^^ reference local value_82 +// ^^^ definition local acc_84 +// ^^^^^^^^^ definition local converter_84 +// ^^^^^^^^^ reference local converter_84 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Function1#apply(). +// ^^^ reference local acc_84 + + /// Traverses the object and casts it down to its basic type: Map, List, or the primitive value. Runs each + /// value through the converter if there is a match. + /// `skipConversion` is a helper flag to avoid infinite recursion in case the converter returns the same type. + local function getBasicValue(value: Any, skipConversion: Boolean) = +// ^^^^^^^^^^^^^ definition local getBasicValue_86 +// documentation +// > Traverses the object and casts it down to its basic type: Map, List, or the primitive value. Runs each +// > value through the converter if there is a match. +// > `skipConversion` is a helper flag to avoid infinite recursion in case the converter returns the same type. +// ^^^^^ definition local value_89 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^^^^^^^^^^ definition local skipConversion_89 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + if (!skipConversion && !getConvertersForValue(value).isEmpty) +// ^^^^^^^^^^^^^^ reference local skipConversion_89 +// ^^^^^^^^^^^^^^^^^^^^^ reference local getConvertersForValue_73 +// ^^^^^ reference local value_89 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. + getBasicValue(applyConverters(value), true) +// ^^^^^^^^^^^^^ reference local getBasicValue_86 +// ^^^^^^^^^^^^^^^ reference local applyConverters_82 +// ^^^^^ reference local value_89 + // If the value is Dynamic, and we have both elements and properties, it's ambiguous whether we should + // render as a table or an array. + else if (value is Dynamic && isTableLike(value) && isArrayLike(value)) +// ^^^^^ reference local value_89 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^^^^^^^^^ reference local isTableLike_113 +// ^^^^^ reference local value_89 +// ^^^^^^^^^^^ reference local isArrayLike_116 +// ^^^^^ reference local value_89 + throw(""" + Cannot render object with both properties/entries and elements as TOML. Received: \(value) +// ^^^^^ reference local value_89 + """) + else if (isTableLike(value)) +// ^^^^^^^^^^^ reference local isTableLike_113 +// ^^^^^ reference local value_89 + getMap(value) +// ^^^^^^ reference local getMap_119 +// ^^^^^ reference local value_89 + .mapValues((_, elem) -> getBasicValue(elem, false)) +// ^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#mapValues(). +// ^^^^ definition local elem_100 +// ^^^^^^^^^^^^^ reference local getBasicValue_86 +// ^^^^ reference local elem_100 + else if (isArrayLike(value)) getList(value).map((elem) -> getBasicValue(elem, false)) +// ^^^^^^^^^^^ reference local isArrayLike_116 +// ^^^^^ reference local value_89 +// ^^^^^^^ reference local getList_122 +// ^^^^^ reference local value_89 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^ definition local elem_101 +// ^^^^^^^^^^^^^ reference local getBasicValue_86 +// ^^^^ reference local elem_101 + else value +// ^^^^^ reference local value_89 + + /// Underlying implementation for rendering values as toml + local function doRenderValue(value: Any, path: List): String = +// ^^^^^^^^^^^^^ definition local doRenderValue_104 +// documentation +// > Underlying implementation for rendering values as toml +// ^^^^^ definition local value_105 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^ definition local path_105 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (isTableArray(value)) +// ^^^^^^^^^^^^ reference local isTableArray_125 +// ^^^^^ reference local value_105 + renderTableArray(value, path) +// ^^^^^^^^^^^^^^^^ reference local renderTableArray_183 +// ^^^^^ reference local value_105 +// ^^^^ reference local path_105 + else if (value is Map) +// ^^^^^ reference local value_105 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# + renderTable(value, path) +// ^^^^^^^^^^^ reference local renderTable_193 +// ^^^^^ reference local value_105 +// ^^^^ reference local path_105 + else + renderInlineValue(value) +// ^^^^^^^^^^^^^^^^^ reference local renderInlineValue_134 +// ^^^^^ reference local value_105 + + /// Determine whether an object is map-like. We'll consider any Dynamic that doesn't have any elements as map-like. + local function isTableLike(obj: Any) = !(obj is AbstractDateTime) && ((obj is Dynamic && obj.toList().isEmpty) || obj is MapLike) +// ^^^^^^^^^^^ definition local isTableLike_113 +// documentation +// > Determine whether an object is map-like. We'll consider any Dynamic that doesn't have any elements as map-like. +// ^^^ definition local obj_114 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference local obj_114 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/AbstractDateTime# +// ^^^ reference local obj_114 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ reference local obj_114 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^ reference local obj_114 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/MapLike# + + /// Determine whether an object is list-like. We'll consider any Dynamic that has elements as list-like. + local function isArrayLike(obj: Any) = (obj is Dynamic && !obj.toList().isEmpty) || obj is ListLike +// ^^^^^^^^^^^ definition local isArrayLike_116 +// documentation +// > Determine whether an object is list-like. We'll consider any Dynamic that has elements as list-like. +// ^^^ definition local obj_117 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^ reference local obj_117 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ reference local obj_117 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^ reference local obj_117 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/ListLike# + + /// Convert an object to its Map representation. Toml doesn't include null so we should filter out null properties. + local function getMap(obj: MapLike|Dynamic) = (if (obj is Map) obj else obj.toMap()).filter((_, elem) -> elem != null) +// ^^^^^^ definition local getMap_119 +// documentation +// > Convert an object to its Map representation. Toml doesn't include null so we should filter out null properties. +// ^^^ definition local obj_120 +// ^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/MapLike# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ reference local obj_120 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^ reference local obj_120 +// ^^^ reference local obj_120 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toMap(). +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^ definition local elem_120 +// ^^^^ reference local elem_120 + + /// Convert an object to its List representation. + local function getList(obj: ListLike|Dynamic) = if (obj is List) obj else obj.toList() +// ^^^^^^^ definition local getList_122 +// documentation +// > Convert an object to its List representation. +// ^^^ definition local obj_123 +// ^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/ListLike# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic# +// ^^^ reference local obj_123 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^ reference local obj_123 +// ^^^ reference local obj_123 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Dynamic#toList(). + + /// Determine if we should render this value as an array of tables or not. + /// A value is an array of tables if all of the inhabitants are table-like. + local function isTableArray(value: Any) = +// ^^^^^^^^^^^^ definition local isTableArray_125 +// documentation +// > Determine if we should render this value as an array of tables or not. +// > A value is an array of tables if all of the inhabitants are table-like. +// ^^^^^ definition local value_127 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + value is List && value.every((elem) -> elem is Map) +// ^^^^^ reference local value_127 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^ reference local value_127 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#every(). +// ^^^^ definition local elem_128 +// ^^^^ reference local elem_128 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# + + local function isTableTypeProp(value: Any) = value is Map || isTableArray(value) +// ^^^^^^^^^^^^^^^ definition local isTableTypeProp_130 +// ^^^^^ definition local value_130 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# +// ^^^^^ reference local value_130 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^^^^^^ reference local isTableArray_125 +// ^^^^^ reference local value_130 + + local convertersMap = converters.toMap() +// ^^^^^^^^^^^^^ definition local convertersMap_132 +// ^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/Renderer#converters. +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping#toMap(). + + /// Render the value as an inline value (e.g. inline array, object, or primitive) + local function renderInlineValue(value: Any) = +// ^^^^^^^^^^^^^^^^^ definition local renderInlineValue_134 +// documentation +// > Render the value as an inline value (e.g. inline array, object, or primitive) +// ^^^^^ definition local value_135 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Any# + if (value is Number && value.isNaN) +// ^^^^^ reference local value_135 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^ reference local value_135 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number#isNaN. + "nan" + else if (value == Infinity) +// ^^^^^ reference local value_135 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Infinity. + "inf" + else if (value is String) +// ^^^^^ reference local value_135 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + renderString(value) +// ^^^^^^^^^^^^ reference local renderString_157 +// ^^^^^ reference local value_135 + else if (value is Number|Boolean) +// ^^^^^ reference local value_135 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Number# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Boolean# + jsonRenderer.renderValue(value) +// ^^^^^^^^^^^^ reference local jsonRenderer_71 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer#renderValue(). +// ^^^^^ reference local value_135 + else if (value is AbstractDateTime) +// ^^^^^ reference local value_135 +// ^^^^^^^^^^^^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/AbstractDateTime# + value.value +// ^^^^^ reference local value_135 +// ^^^^^ reference pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/AbstractDateTime#value. + else if (value is Map) +// ^^^^^ reference local value_135 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# + "{ " + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + for (k, v in value) { +// ^ definition local k_148 +// ^ definition local v_148 +// ^^^^^ reference local value_135 + "\(makeSingleKey(k)) = \(renderInlineValue(v))" +// ^^^^^^^^^^^^^ reference local makeSingleKey_186 +// ^ reference local k_148 +// ^^^^^^^^^^^^^^^^^ reference local renderInlineValue_134 +// ^ reference local v_148 + } + }.toList().join(", ") + " }" +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + else if (value is List) +// ^^^^^ reference local value_135 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# + "[ " + value.map((elem) -> renderInlineValue(elem)).join(", ") + " ]" +// ^^^^^ reference local value_135 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^ definition local elem_153 +// ^^^^^^^^^^^^^^^^^ reference local renderInlineValue_134 +// ^^^^ reference local elem_153 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + else + throw("Not sure how to render value: \(value). Try defining a converter for this type.") +// ^^^^^ reference local value_135 + + /// Render a string making sure multi-line use the """ multi-line syntax for better readability. + local function renderString(value: String) = +// ^^^^^^^^^^^^ definition local renderString_157 +// documentation +// > Render a string making sure multi-line use the """ multi-line syntax for better readability. +// ^^^^^ definition local value_158 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + if (value.contains("\n")) +// ^^^^^ reference local value_158 +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#contains(). + ("\"\"\"\n" + + value.split("\n") +// ^^^^^ reference local value_158 +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#split(). + .map((line) -> jsonRenderer.renderValue(line).drop(1).dropLast(1)) +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^ definition local line_162 +// ^^^^^^^^^^^^ reference local jsonRenderer_71 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer#renderValue(). +// ^^^^ reference local line_162 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#drop(). +// ^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#dropLast(). + .join("\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + "\"\"\"") + else jsonRenderer.renderValue(value) +// ^^^^^^^^^^^^ reference local jsonRenderer_71 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer#renderValue(). +// ^^^^^ reference local value_158 + + local function renderSingleTableArray(map: Map, path: List) = +// ^^^^^^^^^^^^^^^^^^^^^^ definition local renderSingleTableArray_167 +// ^^^ definition local map_167 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^ definition local path_167 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (nativeProps = map.filter((_, value) -> !isTableTypeProp(value))) +// ^^^^^^^^^^^ definition local nativeProps_168 +// ^^^ reference local map_167 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^^ definition local value_168 +// ^^^^^^^^^^^^^^^ reference local isTableTypeProp_130 +// ^^^^^ reference local value_168 + let (tableProps = map.filter((_, value) -> isTableTypeProp(value))) +// ^^^^^^^^^^ definition local tableProps_169 +// ^^^ reference local map_167 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^^ definition local value_169 +// ^^^^^^^^^^^^^^^ reference local isTableTypeProp_130 +// ^^^^^ reference local value_169 + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + """ + + [[\(makeKey(path))]] +// ^^^^^^^ reference local makeKey_191 +// ^^^^ reference local path_167 + """ + for (k, v in nativeProps) { +// ^ definition local k_175 +// ^ definition local v_175 +// ^^^^^^^^^^^ reference local nativeProps_168 + "\(makeSingleKey(k)) = \(renderInlineValue(v))" +// ^^^^^^^^^^^^^ reference local makeSingleKey_186 +// ^ reference local k_175 +// ^^^^^^^^^^^^^^^^^ reference local renderInlineValue_134 +// ^ reference local v_175 + } + for (k, v in tableProps) { +// ^ definition local k_178 +// ^ definition local v_178 +// ^^^^^^^^^^ reference local tableProps_169 + doRenderValue(v, path.add(k)) +// ^^^^^^^^^^^^^ reference local doRenderValue_104 +// ^ reference local v_178 +// ^^^^ reference local path_167 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^ reference local k_178 + } + }.toList().join("\n") +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + local function renderTableArray(value: List, path: List) = +// ^^^^^^^^^^^^^^^^ definition local renderTableArray_183 +// ^^^^^ definition local value_183 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^ definition local path_183 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + value.map((elem) -> renderSingleTableArray(getMap(elem), path)).join("\n") +// ^^^^^ reference local value_183 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^^^^ definition local elem_184 +// ^^^^^^^^^^^^^^^^^^^^^^ reference local renderSingleTableArray_167 +// ^^^^^^ reference local getMap_119 +// ^^^^ reference local elem_184 +// ^^^^ reference local path_183 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + local function makeSingleKey(key: String) = if (key.matches(Regex(#"[A-Za-z0-9_-]+"#))) +// ^^^^^^^^^^^^^ definition local makeSingleKey_186 +// ^^^ definition local key_186 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^ reference local key_186 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String#matches(). +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Regex(). + key +// ^^^ reference local key_186 + else + jsonRenderer.renderValue(key) +// ^^^^^^^^^^^^ reference local jsonRenderer_71 +// ^^^^^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/JsonRenderer#renderValue(). +// ^^^ reference local key_186 + + local function makeKey(path: List): String = path.map((k) -> makeSingleKey(k)).join(".") +// ^^^^^^^ definition local makeKey_191 +// ^^^^ definition local path_191 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^ reference local path_191 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#map(). +// ^ definition local k_191 +// ^^^^^^^^^^^^^ reference local makeSingleKey_186 +// ^ reference local k_191 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + + local function renderTable(m: Map, path: List): String = +// ^^^^^^^^^^^ definition local renderTable_193 +// ^ definition local m_193 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^ definition local path_193 +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/String# + let (nativeProps = m.filter((_, value) -> !isTableTypeProp(value))) +// ^^^^^^^^^^^ definition local nativeProps_194 +// ^ reference local m_193 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^^ definition local value_194 +// ^^^^^^^^^^^^^^^ reference local isTableTypeProp_130 +// ^^^^^ reference local value_194 + let (tableProps = m.filter((_, value) -> isTableTypeProp(value))) +// ^^^^^^^^^^ definition local tableProps_195 +// ^ reference local m_193 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#filter(). +// ^^^^^ definition local value_195 +// ^^^^^^^^^^^^^^^ reference local isTableTypeProp_130 +// ^^^^^ reference local value_195 + new Listing { +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + // Only render the table header if we are in an object's context or empty map context + when (!path.isEmpty && (nativeProps.length > 0 || m.length == 0)) { +// ^^^^ reference local path_193 +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#isEmpty. +// ^^^^^^^^^^^ reference local nativeProps_194 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#length. +// ^ reference local m_193 +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map#length. + """ + + [\(makeKey(path))] +// ^^^^^^^ reference local makeKey_191 +// ^^^^ reference local path_193 + """ + } + for (k, v in nativeProps) { +// ^ definition local k_204 +// ^ definition local v_204 +// ^^^^^^^^^^^ reference local nativeProps_194 + "\(makeSingleKey(k)) = \(renderInlineValue(v))" +// ^^^^^^^^^^^^^ reference local makeSingleKey_186 +// ^ reference local k_204 +// ^^^^^^^^^^^^^^^^^ reference local renderInlineValue_134 +// ^ reference local v_204 + } + for (k, v in tableProps) { +// ^ definition local k_207 +// ^ definition local v_207 +// ^^^^^^^^^^ reference local tableProps_195 + doRenderValue(v, path.add(k)) +// ^^^^^^^^^^^^^ reference local doRenderValue_104 +// ^ reference local v_207 +// ^^^^ reference local path_193 +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#add(). +// ^ reference local k_207 + } + } + .toList() +// ^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing#toList(). + .join("\n") +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List#join(). + } + + local typealias MapLike = Typed|Map|Mapping +// ^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/MapLike# +// ^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Typed# +// ^^^ reference pkl . pkl 0.29.0 `pkl.base`/Map# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Mapping# + + local typealias ListLike = List|Listing +// ^^^^^^^^ definition pkl . package://pkg.pkl-lang.org/pkl-pantry/pkl.toml 1.0.2 `toml.pkl`/ListLike# +// ^^^^ reference pkl . pkl 0.29.0 `pkl.base`/List# +// ^^^^^^^ reference pkl . pkl 0.29.0 `pkl.base`/Listing# + diff --git a/src/main/kotlin/org/pkl/lsp/cli/LspCommand.kt b/src/main/kotlin/org/pkl/lsp/cli/LspCommand.kt index c59020da..3ecdcf9c 100644 --- a/src/main/kotlin/org/pkl/lsp/cli/LspCommand.kt +++ b/src/main/kotlin/org/pkl/lsp/cli/LspCommand.kt @@ -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. @@ -19,14 +19,9 @@ import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.Context import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.clikt.parameters.options.versionOption import org.pkl.lsp.PklLsp -import org.pkl.lsp.Release -class LspCommand : CliktCommand(name = "pkl-lsp") { - init { - versionOption(version = Release.version) - } +class LspCommand : CliktCommand(name = "server") { private val verbose: Boolean by option(names = arrayOf("--verbose"), help = "Send debug information to the client") diff --git a/src/main/kotlin/org/pkl/lsp/cli/Main.kt b/src/main/kotlin/org/pkl/lsp/cli/Main.kt index 754e2ead..732b3112 100644 --- a/src/main/kotlin/org/pkl/lsp/cli/Main.kt +++ b/src/main/kotlin/org/pkl/lsp/cli/Main.kt @@ -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,5 +20,5 @@ package org.pkl.lsp.cli import com.github.ajalt.clikt.core.main internal fun main(args: Array) { - LspCommand().main(args) + PklLspCliCommand().main(args) } diff --git a/src/main/kotlin/org/pkl/lsp/cli/PklLspCliCommand.kt b/src/main/kotlin/org/pkl/lsp/cli/PklLspCliCommand.kt new file mode 100644 index 00000000..d4660820 --- /dev/null +++ b/src/main/kotlin/org/pkl/lsp/cli/PklLspCliCommand.kt @@ -0,0 +1,32 @@ +/* + * Copyright © 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.pkl.lsp.cli + +import com.github.ajalt.clikt.core.Context +import com.github.ajalt.clikt.core.NoOpCliktCommand +import com.github.ajalt.clikt.core.subcommands +import com.github.ajalt.clikt.parameters.options.versionOption +import org.pkl.lsp.Release + +class PklLspCliCommand : NoOpCliktCommand(name = "pkl-lsp") { + init { + versionOption(version = Release.version) + subcommands(LspCommand(), ScipCommand()) + } + + override fun help(context: Context): String = + "Pkl Language Server with support for LSP and SCIP indexing" +} diff --git a/src/main/kotlin/org/pkl/lsp/cli/ScipCommand.kt b/src/main/kotlin/org/pkl/lsp/cli/ScipCommand.kt new file mode 100644 index 00000000..f402d4b7 --- /dev/null +++ b/src/main/kotlin/org/pkl/lsp/cli/ScipCommand.kt @@ -0,0 +1,282 @@ +/* + * Copyright © 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.pkl.lsp.cli + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.Context +import com.github.ajalt.clikt.parameters.arguments.argument +import com.github.ajalt.clikt.parameters.arguments.multiple +import com.github.ajalt.clikt.parameters.options.default +import com.github.ajalt.clikt.parameters.options.option +import com.github.ajalt.clikt.parameters.types.path +import java.io.FileOutputStream +import java.io.IOException +import java.nio.file.Path +import kotlin.io.path.* +import kotlin.system.exitProcess +import org.eclipse.lsp4j.* +import org.pkl.lsp.PklLanguageClient +import org.pkl.lsp.PklLspServer +import org.pkl.lsp.Project +import org.pkl.lsp.messages.ActionableNotification +import org.pkl.lsp.scip.ScipAnalyzer +import org.pkl.lsp.scip.ScipAnalysisException +import org.pkl.lsp.util.PathUtils + +// Custom exceptions for CLI operations +sealed class ScipCommandException(message: String, cause: Throwable? = null) : Exception(message, cause) { + + class FileProcessingException( + filePath: Path, + cause: Throwable + ) : ScipCommandException("Failed to process file: $filePath", cause) + + class IndexWriteException( + outputPath: Path, + cause: Throwable + ) : ScipCommandException("Failed to write SCIP index to: $outputPath", cause) + + class ProjectSetupException( + message: String, + cause: Throwable + ) : ScipCommandException("Failed to set up LSP project: $message", cause) +} + +class ScipCommand : CliktCommand(name = "scip") { + + private val outputFile: Path by + option("--output", "-o", help = "Output file for SCIP index (default: index.scip)") + .path() + .default(Path.of("index.scip")) + + private val sourceRoots: List by + argument(help = "Source directories or files to index") + .path(mustExist = true) + .multiple(required = true) + + override fun help(context: Context): String = + "Generate SCIP (Source Code Intelligence Protocol) index for Pkl source files" + + override fun run() { + val indexingService = ScipIndexingService() + + when (val result = indexingService.generateIndex( + sourceRoots = sourceRoots, + outputFile = outputFile, + onProgress = ::echo + )) { + is IndexingResult.Success -> { + echo("SCIP index written to ${result.outputFile}") + echo("Index contains ${result.documentCount} documents and ${result.symbolCount} symbols") + } + is IndexingResult.Failure -> { + echo("Error generating SCIP index: ${result.error.message}", err = true) + result.error.printStackTrace() + exitProcess(1) + } + } + } + + // Path resolution with lazy properties + class PathResolver(private val sourceRoots: List) { + val folders by lazy { sourceRoots.filter(Path::isDirectory).map(Path::toRealPath) } + val files by lazy { sourceRoots.filter(Path::isRegularFile).map(Path::toRealPath) } + val commonRoot by lazy { PathUtils.findCommonRoot(folders + PathUtils.findCommonRoot(files)) } + val workspaceFolders by lazy { folders + PathUtils.findCommonRoot(files) } + val pklFiles by lazy { PathUtils.findPklFiles(files + folders) } + } + + // Result sealed class for type-safe results + sealed class IndexingResult { + data class Success( + val documentCount: Int, + val symbolCount: Int, + val outputFile: Path + ) : IndexingResult() + + data class Failure(val error: Throwable) : IndexingResult() + } + + // Service class for SCIP indexing logic + class ScipIndexingService { + fun generateIndex( + sourceRoots: List, + outputFile: Path, + onProgress: (String) -> Unit = {} + ): IndexingResult { + return try { + val pathResolver = PathResolver(sourceRoots) + val (project, server) = createProjectWithServer(pathResolver.workspaceFolders, verbose = true) + + try { + val analyzer = ScipAnalyzer(project, pathResolver.commonRoot) + + pathResolver.pklFiles.forEachIndexed { index, pklFile -> + onProgress("Processing $pklFile (${index + 1}/${pathResolver.pklFiles.size})") + + try { + val absolutePath = pklFile.toAbsolutePath() + val virtualFile = project.virtualFileManager.get(absolutePath.toUri()) + if (virtualFile != null) { + analyzer.analyzeFile(virtualFile) + } else { + onProgress("Warning: Could not load $absolutePath") + } + } catch (e: ScipAnalysisException) { + onProgress("SCIP analysis error in $pklFile: ${e.message}") + } catch (e: IOException) { + onProgress("I/O error processing $pklFile: ${e.message}") + } catch (e: Exception) { + onProgress("Unexpected error processing $pklFile: ${e.message}") + e.printStackTrace() + } + } + + val index = analyzer.buildIndex() + writeIndex(index, outputFile) + + IndexingResult.Success( + documentCount = index.documentsCount, + symbolCount = index.externalSymbolsCount + index.documentsList.sumOf { it.symbolsCount }, + outputFile = outputFile + ) + } finally { + server.shutdown().get() + server.exit() + } + } catch (e: ScipCommandException) { + IndexingResult.Failure(e) + } catch (e: ScipAnalysisException) { + IndexingResult.Failure(e) + } catch (e: IOException) { + IndexingResult.Failure(ScipCommandException.IndexWriteException(outputFile, e)) + } catch (e: Exception) { + IndexingResult.Failure(ScipCommandException.ProjectSetupException("Unexpected error", e)) + } + } + + private fun writeIndex(index: scip.Scip.Index, outputFile: Path) { + try { + outputFile.parent?.createDirectories() + outputFile.toFile().outputStream().use { output -> + index.writeTo(output) + } + } catch (e: IOException) { + throw ScipCommandException.IndexWriteException(outputFile, e) + } catch (e: Exception) { + throw ScipCommandException.IndexWriteException(outputFile, e) + } + } + } + + // Data class for LSP server configuration + data class LspServerConfig( + val workspaceFolders: List, + val verbose: Boolean = true + ) { + val workspaceFoldersLsp: List by lazy { + workspaceFolders.map { folder -> + WorkspaceFolder().apply { + uri = folder.toUri().toString() + name = folder.fileName?.toString() ?: "workspace" + } + } + } + } + + companion object { + data class ProjectWithServer(val project: Project, val server: PklLspServer) + + // Extension function for server configuration + private fun PklLspServer.configureWith(client: PklLanguageClient, config: LspServerConfig) = apply { + connect(client) + + val initParams = InitializeParams().apply { + capabilities = ClientCapabilities().apply { + workspace = WorkspaceClientCapabilities().apply { + workspaceFolders = true + didChangeConfiguration = DidChangeConfigurationCapabilities().apply { + dynamicRegistration = false + } + } + textDocument = TextDocumentClientCapabilities() + } + workspaceFolders = config.workspaceFoldersLsp + } + + initialize(initParams).get() + initialized(InitializedParams()) + syncProjects("").get() + } + + // Extension for project initialization + private fun Project.ensureInitialized() = apply { initialize().get() } + + // Extract client creation + private fun createLspClient(config: LspServerConfig) = object : PklLanguageClient { + private fun log(message: String) { + if (config.verbose) println(message) + } + + override fun sendActionableNotification(params: ActionableNotification) = + log("LSP Actionable Notification: $params") + + override fun telemetryEvent(`object`: Any?) = + log("LSP Telemetry: $`object`") + + override fun publishDiagnostics(diagnostics: PublishDiagnosticsParams?) = + log("LSP Diagnostics for ${diagnostics?.uri}: ${diagnostics?.diagnostics}") + + override fun showMessage(messageParams: MessageParams?) = + log("LSP Message: [${messageParams?.type}] ${messageParams?.message}") + + override fun showMessageRequest(requestParams: ShowMessageRequestParams?) = + java.util.concurrent.CompletableFuture() + + override fun logMessage(message: MessageParams) = + log("LSP Log: [${message.type}] ${message.message}") + + override fun workspaceFolders() = + java.util.concurrent.CompletableFuture.completedFuture(config.workspaceFoldersLsp) + + override fun configuration(configurationParams: ConfigurationParams): java.util.concurrent.CompletableFuture> = + java.util.concurrent.CompletableFuture.completedFuture( + configurationParams.items.map { com.google.gson.JsonNull.INSTANCE as Any? }.toMutableList() + ).also { + if (config.verbose) { + val sections = configurationParams.items.joinToString { "${it.scopeUri}/${it.section}" } + log("Configuration requested: $sections") + } + } + } + + /** + * Creates an LSP server and project for specific workspace folders. + */ + fun createProjectWithServer( + workspaceFolders: List, + verbose: Boolean = true + ): ProjectWithServer { + val config = LspServerConfig(workspaceFolders, verbose) + val client = createLspClient(config) + val server = PklLspServer(verbose).configureWith(client, config) + val project = server.project.ensureInitialized() + + return ProjectWithServer(project, server) + } + + } +} diff --git a/src/main/kotlin/org/pkl/lsp/scip/PklNodeSymbolCreator.kt b/src/main/kotlin/org/pkl/lsp/scip/PklNodeSymbolCreator.kt new file mode 100644 index 00000000..343230ad --- /dev/null +++ b/src/main/kotlin/org/pkl/lsp/scip/PklNodeSymbolCreator.kt @@ -0,0 +1,182 @@ +/* + * Copyright © 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.pkl.lsp.scip + +import org.pkl.lsp.ast.* +import org.pkl.lsp.packages.dto.PklProject +import org.pkl.lsp.packages.dto.PackageUri +import scip.Scip.* + +/** + * Handles symbol creation for different Pkl AST node types. + * This class encapsulates the logic for creating SCIP symbols based on Pkl-specific nodes, + * making it easier to maintain and extend as new node types are added. + */ +class PklNodeSymbolCreator( + private val symbolFormatter: ScipSymbolFormatter, + private val getParentDescriptors: (PklNode) -> String +) { + + data class PackageInfo(val name: String, val version: String) + + private val UNKNOWN_PACKAGE = PackageInfo(".", ".") + + /** + * Creates a SCIP symbol for the given Pkl node definition. + */ + fun createSymbolForDefinition(definition: PklNode, packageInfo: PackageInfo): String { + return when (definition) { + is PklModule -> createModuleSymbol(definition, packageInfo) + is PklClass -> createClassSymbol(definition, packageInfo) + is PklClassMethod -> createClassMethodSymbol(definition, packageInfo) + is PklClassProperty -> createClassPropertySymbol(definition, packageInfo) + is PklObjectProperty -> createObjectPropertySymbol(definition, packageInfo) + is PklTypedIdentifier -> createTypedIdentifierSymbol(definition) + is PklTypeAlias -> createTypeAliasSymbol(definition, packageInfo) + else -> throw ScipAnalysisException.UnknownDefinitionTypeException( + nodeType = definition::class.simpleName ?: "Unknown" + ) + } + } + + /** + * Creates symbol for module nodes (top-level files). + */ + private fun createModuleSymbol(module: PklModule, packageInfo: PackageInfo): String { + return symbolFormatter.formatSymbol(module, packageInfo.name, packageInfo.version) + } + + /** + * Creates symbol for class definitions, handling local vs nested scope. + */ + private fun createClassSymbol(clazz: PklClass, packageInfo: PackageInfo): String { + return if ((clazz as? PklModifierListOwner)?.isLocal == true) { + symbolFormatter.formatLocalSymbol(clazz.name, clazz.span) + } else { + val parentDescriptors = getParentDescriptors(clazz) + symbolFormatter.formatNestedSymbol(clazz, parentDescriptors, packageInfo) + } + } + + /** + * Creates symbol for class method definitions, handling local vs nested scope. + */ + private fun createClassMethodSymbol(method: PklClassMethod, packageInfo: PackageInfo): String { + return if ((method as? PklModifierListOwner)?.isLocal == true) { + symbolFormatter.formatLocalSymbol(method.name, method.span) + } else { + val parentDescriptors = getParentDescriptors(method) + symbolFormatter.formatNestedSymbol(method, parentDescriptors, packageInfo) + } + } + + /** + * Creates symbol for class property definitions, handling identifier extraction and scope. + */ + private fun createClassPropertySymbol(property: PklClassProperty, packageInfo: PackageInfo): String { + return if ((property as? PklModifierListOwner)?.isLocal == true) { + val identifier = property.identifier ?: throw ScipAnalysisException.IdentifierExtractionException( + nodeType = "PklClassProperty", + location = property.span + ) + symbolFormatter.formatLocalSymbol(identifier.text, property.span) + } else { + val parentDescriptors = getParentDescriptors(property) + symbolFormatter.formatNestedSymbol(property, parentDescriptors, packageInfo) + } + } + + /** + * Creates symbol for object property definitions, handling identifier extraction and scope. + */ + private fun createObjectPropertySymbol(property: PklObjectProperty, packageInfo: PackageInfo): String { + return if ((property as? PklModifierListOwner)?.isLocal == true) { + val identifier = property.identifier ?: throw ScipAnalysisException.IdentifierExtractionException( + nodeType = "PklObjectProperty", + location = property.span + ) + symbolFormatter.formatLocalSymbol(identifier.text, property.span) + } else { + val parentDescriptors = getParentDescriptors(property) + symbolFormatter.formatNestedSymbol(property, parentDescriptors, packageInfo) + } + } + + /** + * Creates symbol for typed identifier nodes (parameters, local variables). + * These are always treated as local symbols. + */ + private fun createTypedIdentifierSymbol(typedId: PklTypedIdentifier): String { + val identifier = typedId.identifier ?: throw ScipAnalysisException.IdentifierExtractionException( + nodeType = "PklTypedIdentifier", + location = typedId.span + ) + return symbolFormatter.formatLocalSymbol(identifier.text, typedId.span) + } + + /** + * Creates symbol for type alias definitions. + * These are always treated as nested (non-local) symbols. + */ + private fun createTypeAliasSymbol(typeAlias: PklTypeAlias, packageInfo: PackageInfo): String { + val parentDescriptors = getParentDescriptors(typeAlias) + return symbolFormatter.formatNestedSymbol(typeAlias, parentDescriptors, packageInfo) + } + + /** + * Extracts package information from various Pkl project contexts. + */ + fun getPackageInfoForProject(pklProject: PklProject?): PackageInfo = + if (pklProject != null) { + val packageName = pklProject.metadata?.packageUri?.toString()?.substringBeforeLast("@") ?: "." + val packageVersion = pklProject.metadata?.packageUri?.version?.toString() ?: "." + PackageInfo(packageName, packageVersion) + } else { + UNKNOWN_PACKAGE + } + + /** + * Extracts package information from a PackageUri. + */ + fun getPackageInfo(packageUri: PackageUri): PackageInfo { + val packageName = packageUri.toString().substringBeforeLast("@") + val packageVersion = packageUri.version.toString() + return PackageInfo(packageName, packageVersion) + } + + /** + * Extracts package information for a specific module, handling built-in modules. + */ + fun getPackageInfoForModule(module: PklModule): PackageInfo { + val pklProject = module.containingFile.pklProject + val pklPackage = module.containingFile.`package` + + if (module.uri.toString().startsWith("pkl:")) { + // For built-in modules + return PackageInfo("pkl", module.effectivePklVersion.toString()) + } + + return when { + pklProject != null -> getPackageInfoForProject(pklProject) + pklPackage != null -> { + val packageName = pklPackage.packageUri.toString().substringBeforeLast("@") + val packageVersion = pklPackage.packageUri.version.toString() + PackageInfo(packageName, packageVersion) + } + else -> UNKNOWN_PACKAGE + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/org/pkl/lsp/scip/ScipAnalyzer.kt b/src/main/kotlin/org/pkl/lsp/scip/ScipAnalyzer.kt new file mode 100644 index 00000000..64cad2b8 --- /dev/null +++ b/src/main/kotlin/org/pkl/lsp/scip/ScipAnalyzer.kt @@ -0,0 +1,268 @@ +/* + * Copyright © 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.pkl.lsp.scip + +import java.nio.file.Path +import org.pkl.lsp.Component +import org.pkl.lsp.Project +import org.pkl.lsp.VirtualFile +import org.pkl.lsp.ast.* +import org.pkl.lsp.packages.dto.PackageUri +import org.pkl.lsp.packages.dto.PklProject +import scip.Scip.* + +// Custom exception types for better error handling +sealed class ScipAnalysisException(message: String, cause: Throwable? = null) : Exception(message, cause) { + + class ReferenceResolutionException( + identifier: String, + location: Span, + cause: Throwable? = null + ) : ScipAnalysisException("Failed to resolve reference '$identifier' at $location", cause) + + class ModuleResolutionException( + identifier: String, + cause: Throwable? = null + ) : ScipAnalysisException("Failed to resolve enclosing module for '$identifier'", cause) + + class NameExtractionException( + nodeType: String, + location: Span + ) : ScipAnalysisException("Unable to extract name from $nodeType at $location") + + class IdentifierExtractionException( + nodeType: String, + location: Span + ) : ScipAnalysisException("Unable to extract identifier from $nodeType at $location") + + class UnknownDefinitionTypeException( + nodeType: String + ) : ScipAnalysisException("Unknown definition type: $nodeType") +} + + +class ScipAnalyzer(project: Project, rootPath: Path) : Component(project) { + + private val indexBuilder = ScipIndexBuilder(rootPath) + private val symbolFormatter = ScipSymbolFormatter(rootPath) + private val symbolCreator = PklNodeSymbolCreator(symbolFormatter, ::getParentDescriptors) + + private fun getPackageInfo(context: PklProject?): PklNodeSymbolCreator.PackageInfo = + symbolCreator.getPackageInfoForProject(context) + + fun analyzeFile(file: VirtualFile): ScipDocumentBuilder { + val docBuilder = indexBuilder.addDocument(file) + val module = file.getModule().get() ?: return docBuilder + val context = module.containingFile.pklProject + + analyzeNode(module, docBuilder, context) + return docBuilder + } + + // Extension function to handle common definition node pattern + private inline fun PklNode.handleAsDefinition( + docBuilder: ScipDocumentBuilder, + context: PklProject?, + packageInfo: PklNodeSymbolCreator.PackageInfo, + crossinline additionalCheck: () -> Boolean = { true } + ) { + if (additionalCheck()) { + val symbol = symbolCreator.createSymbolForDefinition(this, packageInfo) + addSymbolDefinition(this, symbol, docBuilder, context) + } + children.forEach { analyzeNode(it, docBuilder, context) } + } + + private fun analyzeNode(node: PklNode, docBuilder: ScipDocumentBuilder, context: PklProject?) { + val packageInfo = getPackageInfo(context) + + when (node) { + is PklModule -> { + val symbol = symbolFormatter.formatSymbol(node, packageInfo.name, packageInfo.version) + addSymbolDefinition(node, symbol, docBuilder, context) + node.children.forEach { child -> analyzeNode(child, docBuilder, context) } + } + + is PklClass -> node.handleAsDefinition(docBuilder, context, packageInfo) + is PklClassMethod -> node.handleAsDefinition(docBuilder, context, packageInfo) + is PklClassProperty -> node.handleAsDefinition(docBuilder, context, packageInfo) + is PklObjectProperty -> node.handleAsDefinition(docBuilder, context, packageInfo) + is PklTypeAlias -> node.handleAsDefinition(docBuilder, context, packageInfo) + is PklTypedIdentifier -> node.handleAsDefinition(docBuilder, context, packageInfo) { + node.identifier != null + } + + is PklAccessExpr -> { + analyzeReference(node, docBuilder, context) + node.children.forEach { child -> analyzeNode(child, docBuilder, context) } + } + + is PklTypeName -> { + analyzeReference(node, docBuilder, context) + node.children.forEach { child -> analyzeNode(child, docBuilder, context) } + } + + else -> { + node.children.forEach { child -> analyzeNode(child, docBuilder, context) } + } + } + } + + private fun createSymbolInformation(node: PklNode, symbol: String): SymbolInformation { + val builder = + SymbolInformation.newBuilder().setSymbol(symbol).setKind(symbolFormatter.getSymbolKind(node)) + + if (node is PklDocCommentOwner) { + node.effectiveDocComment(node.containingFile?.pklProject)?.let { doc -> + builder.addDocumentation(doc) + } + } + + if (node is PklNamedNode) { + builder.setDisplayName(node.name) + } + + return builder.build() + } + + private fun addSymbolDefinition( + node: PklNode, + symbol: String, + docBuilder: ScipDocumentBuilder, + context: PklProject?, + ) { + val span = + when (node) { + is IdentifierOwner -> node.identifier?.span ?: return + is PklModule -> node.header?.moduleClause?.span ?: return + else -> return + } + + docBuilder.addOccurrence( + span, + symbol, + SymbolRole.Definition, + symbolFormatter.getSymbolKind(node), + ) + + val symbolInfo = createSymbolInformation(node, symbol) + docBuilder.addSymbol(symbol, symbolInfo) + } + + private fun analyzeReference( + reference: PklNode, + docBuilder: ScipDocumentBuilder, + context: PklProject?, + ) { + val (identifier, resolvedDefinition) = + when (reference) { + is PklAccessExpr -> Pair(reference.identifier, reference.resolve(context)) + is PklTypeName -> Pair(reference.simpleTypeName.identifier, reference.resolve(context)) + else -> return + } + if (identifier == null) return + try { + if (resolvedDefinition == null) { + throw ScipAnalysisException.ReferenceResolutionException( + identifier = identifier.text, + location = identifier.span + ) + } + val definitionModule = resolvedDefinition.enclosingModule + ?: throw ScipAnalysisException.ModuleResolutionException( + identifier = identifier.text + ) + + val symbol = + symbolCreator.createSymbolForDefinition(resolvedDefinition, symbolCreator.getPackageInfoForModule(definitionModule)) + + val kind = + when { + (reference is PklAccessExpr && reference.isPropertyAccess) -> + SymbolInformation.Kind.Property + reference is PklQualifiedAccessExpr -> SymbolInformation.Kind.Method + reference is PklUnqualifiedAccessExpr -> SymbolInformation.Kind.Function + reference is PklTypeName -> SymbolInformation.Kind.Type + else -> SymbolInformation.Kind.UnspecifiedKind + } + + docBuilder.addOccurrence(identifier.span, symbol, SymbolRole.ReadAccess, kind) + + // Use the generated symbol to determine if symbol is a local symbol. If so don't add it to + // the external symbols in the index + if (isFromDifferentProject(definitionModule, context)) { + indexBuilder.addExternalSymbolDefinition( + symbol, + createSymbolInformation(resolvedDefinition, symbol), + ) + } + } catch (e: ScipAnalysisException) { + // Log specific analysis errors with better context + project + .getLogger(this::class) + .error("SCIP analysis error for reference `${identifier.text}` at ${reference.span}: ${e.message}") + } catch (e: Exception) { + // Log unexpected errors for debugging + project + .getLogger(this::class) + .error("Unexpected error processing reference `${identifier.text}` at ${reference.span}: ${e.message}") + } + } + + fun buildIndex(): Index { + return indexBuilder.build() + } + + private fun isFromDifferentProject( + definitionModule: PklModule, + currentProject: PklProject?, + ): Boolean { + val definitionProject = definitionModule.containingFile?.pklProject + + return when { + // If current project is null, assume everything is external + currentProject == null -> true + + // If definition project is null, it's likely stdlib/external + definitionProject == null -> true + + // Compare projects + else -> definitionProject != currentProject + } + } + + + + private fun getParentDescriptors(node: PklNode): String { + val parents = mutableListOf() + var current = node.parent + + while (current != null) { + when (current) { + is PklModule -> { + parents.add(symbolFormatter.getDescriptor(current)) + break + } + is PklClass -> { + parents.add(symbolFormatter.getDescriptor(current)) + } + } + current = current.parent + } + + return parents.reversed().joinToString("") + } +} diff --git a/src/main/kotlin/org/pkl/lsp/scip/ScipIndexBuilder.kt b/src/main/kotlin/org/pkl/lsp/scip/ScipIndexBuilder.kt new file mode 100644 index 00000000..4b266ade --- /dev/null +++ b/src/main/kotlin/org/pkl/lsp/scip/ScipIndexBuilder.kt @@ -0,0 +1,404 @@ +/* + * Copyright © 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.pkl.lsp.scip + +import java.nio.file.Path +import kotlin.io.path.relativeTo +import org.pkl.lsp.Release +import org.pkl.lsp.VirtualFile +import org.pkl.lsp.ast.* +import scip.Scip.* + +class ScipIndexBuilder( + private val rootPath: Path, + private val toolInfo: ToolInfo = + ToolInfo.newBuilder().setName("pkl-lsp").setVersion(Release.version).build(), +) { + private val documents = mutableMapOf() + private val symbolInfos = mutableMapOf() + + fun addDocument(file: VirtualFile): ScipDocumentBuilder { + val relativePath = file.path.relativeTo(rootPath).toString() + val builder = ScipDocumentBuilder(relativePath, file) + documents[relativePath] = builder + return builder + } + + fun addExternalSymbolDefinition(symbol: String, info: SymbolInformation) { + // Always canonicalize symbols before storing + val canonicalSymbol = ScipCanonicalizer.canonicalizeSymbol(symbol) + symbolInfos[canonicalSymbol] = info + } + + fun build(): Index { + val builtDocs = documents.values.map { it.build() } + + // Remove duplicate symbols that have been duplicated in external symbols. Happens when indexing + // multiple packages at the same time that take dependencies on each other + val docSymbols = + builtDocs.fold( + mutableSetOf(), + { seen, doc -> seen.apply { addAll(doc.symbolsList.map { it.symbol }) } }, + ) + + docSymbols.forEach { symbolInfos.remove(it) } + + return Index.newBuilder() + .setMetadata( + Metadata.newBuilder() + .setVersion(ProtocolVersion.UnspecifiedProtocolVersion) + .setToolInfo(toolInfo) + .setProjectRoot("file://${rootPath}") + .build() + ) + .addAllDocuments(builtDocs) + .addAllExternalSymbols(symbolInfos.values) + .build() + } +} + +class ScipDocumentBuilder(private val relativePath: String, private val file: VirtualFile) { + private val occurrences = mutableListOf() + private val documentSymbols = mutableMapOf() + + fun addOccurrence( + span: org.pkl.lsp.ast.Span, + symbol: String, + role: SymbolRole, + kind: SymbolInformation.Kind = SymbolInformation.Kind.UnspecifiedKind, + ) { + val range = intArrayOf(span.beginLine - 1, span.beginCol - 1, span.endLine - 1, span.endCol - 1) + + // Always canonicalize symbols before adding occurrences + val canonicalSymbol = ScipCanonicalizer.canonicalizeSymbol(symbol) + + occurrences.add( + Occurrence.newBuilder() + .addAllRange(range.toList()) + .setSymbol(canonicalSymbol) + .setSymbolRoles(role.getNumber()) + .build() + ) + } + + fun addSymbol(symbol: String, info: SymbolInformation) { + // Always canonicalize symbols before storing + val canonicalSymbol = ScipCanonicalizer.canonicalizeSymbol(symbol) + documentSymbols[canonicalSymbol] = info + } + + fun build(): Document { + return Document.newBuilder() + .setRelativePath(relativePath) + .setLanguage("pkl") + .setText(file.contents) + .addAllOccurrences(occurrences.sortedBy { it.getRange(0) * 10000 + it.getRange(1) }) + .addAllSymbols(documentSymbols.values) + .build() + } +} + +/** + * Unified SCIP symbol canonicalization system following SCIP protocol specification. All symbol + * formatting should go through this system to ensure consistency. + */ +object ScipCanonicalizer { + /** + * Canonicalize any identifier according to SCIP rules: + * - simple-identifier: '_' | '+' | '-' | '$' | ASCII letter or digit + * - escaped-identifier: '`' ... '`' (only when contains non-simple characters) + * - Canonical rule: Use simple-identifier if possible, escaped-identifier only when necessary + */ + fun canonicalizeIdentifier(name: String): String { + if (name.isEmpty()) return name + + // Remove surrounding backticks if present (PKL escaping) + val withoutBackticks = + if (name.startsWith("`") && name.endsWith("`")) { + name.substring(1, name.length - 1) + } else { + name + } + + // Check if the name can be represented as a simple identifier + // SCIP simple-identifier: '_' | '+' | '-' | '$' | ASCII letter or digit + val isSimpleIdentifier = + withoutBackticks.all { char -> + char == '_' || + char == '+' || + char == '-' || + char == '$' || + (char in 'a'..'z') || + (char in 'A'..'Z') || + (char in '0'..'9') + } + + return if (isSimpleIdentifier && withoutBackticks.isNotEmpty()) { + // Can use simple identifier format - no backticks needed + withoutBackticks + } else { + // Must use escaped identifier format with backticks + // Escape internal backticks by doubling them + val escapedContent = withoutBackticks.replace("`", "``") + "`$escapedContent`" + } + } + + // Sealed class for descriptor types with pattern matching + private sealed class DescriptorPattern(val predicate: (String) -> Boolean) { + abstract fun canonicalize(descriptor: String): String + + data object TypeDescriptor : DescriptorPattern({ it.endsWith("#") }) { + override fun canonicalize(descriptor: String): String { + val name = descriptor.dropLast(1) + return "${canonicalizeIdentifier(name)}#" + } + } + + data object TermDescriptor : DescriptorPattern({ it.endsWith(".") && !it.endsWith(").") }) { + override fun canonicalize(descriptor: String): String { + val name = descriptor.dropLast(1) + return "${canonicalizeIdentifier(name)}." + } + } + + data object MethodDescriptor : DescriptorPattern({ it.endsWith(").") }) { + override fun canonicalize(descriptor: String): String { + val beforeParen = descriptor.substringBeforeLast("(") + val afterParen = descriptor.substringAfterLast("(") + return "${canonicalizeIdentifier(beforeParen)}($afterParen" + } + } + + data object NamespaceDescriptor : DescriptorPattern({ it.endsWith("/") }) { + override fun canonicalize(descriptor: String): String { + val name = descriptor.dropLast(1) + return "${canonicalizeIdentifier(name)}/" + } + } + + data object MetaDescriptor : DescriptorPattern({ it.endsWith(":") }) { + override fun canonicalize(descriptor: String): String { + val name = descriptor.dropLast(1) + return "${canonicalizeIdentifier(name)}:" + } + } + + data object MacroDescriptor : DescriptorPattern({ it.endsWith("!") }) { + override fun canonicalize(descriptor: String): String { + val name = descriptor.dropLast(1) + return "${canonicalizeIdentifier(name)}!" + } + } + + data object TypeParameter : DescriptorPattern({ it.startsWith("[") && it.endsWith("]") }) { + override fun canonicalize(descriptor: String): String { + val name = descriptor.substring(1, descriptor.length - 1) + return "[${canonicalizeIdentifier(name)}]" + } + } + + data object Parameter : DescriptorPattern({ it.startsWith("(") && it.endsWith(")") }) { + override fun canonicalize(descriptor: String): String { + val name = descriptor.substring(1, descriptor.length - 1) + return "(${canonicalizeIdentifier(name)})" + } + } + + companion object { + // Order matters - more specific patterns should come first + val patterns = listOf( + MethodDescriptor, // Must come before TermDescriptor + TypeDescriptor, + TermDescriptor, + NamespaceDescriptor, + MetaDescriptor, + MacroDescriptor, + TypeParameter, + Parameter + ) + } + } + + /** + * Canonicalize SCIP descriptors using strategy pattern for better maintainability. + */ + fun canonicalizeDescriptor(descriptor: String): String { + if (descriptor.isEmpty()) return descriptor + + return DescriptorPattern.patterns + .find { it.predicate(descriptor) } + ?.canonicalize(descriptor) + ?: descriptor // Return as-is for unknown patterns + } + + /** + * Canonicalize a complete SCIP symbol string. Handles both local symbols and full symbols with + * scheme/package/descriptors. + */ + fun canonicalizeSymbol(symbol: String): String { + if (symbol.isEmpty()) return symbol + + return when { + // Local symbol: "local " + symbol.startsWith("local ") -> { + val localId = symbol.substring(6) + "local ${canonicalizeIdentifier(localId)}" + } + // Full symbol: " " + else -> { + val parts = symbol.split(" ") + if (parts.size >= 5) { + val scheme = parts[0] + val manager = parts[1] + val packageName = parts[2] + val version = parts[3] + val descriptors = parts.drop(4).joinToString(" ") + + // Canonicalize each descriptor part + val canonicalDescriptors = + descriptors + .split(Regex("(?=[#./:\\[(!])")) + .filter { it.isNotEmpty() } + .joinToString("") { canonicalizeDescriptor(it) } + + "$scheme $manager $packageName $version $canonicalDescriptors" + } else { + symbol // Return as-is if format doesn't match expected pattern + } + } + } + } +} + +class ScipSymbolFormatter(val rootPath: Path) { + private val SCHEME = "pkl" + private val MANAGER = "." // Use placeholder for no package manager + private val DEFAULT_PACKAGE = "local" + private val DEFAULT_VERSION = "0.0.0" + + /** + * Generate proper SCIP symbol following the format: ' ' ' ' ()+ + * where = ' ' ' ' + */ + fun formatSymbol( + node: PklNode, + packageName: String = DEFAULT_PACKAGE, + version: String = DEFAULT_VERSION, + ): String { + val packagePart = "$MANAGER $packageName $version" + val descriptor = getDescriptor(node) + return "$SCHEME $packagePart $descriptor" + } + + /** Generate symbol with parent context for nested symbols */ + fun formatNestedSymbol( + node: PklNode, + parentDescriptors: String, + packageInfo: PklNodeSymbolCreator.PackageInfo, + ): String { + val packagePart = "$MANAGER ${packageInfo.name} ${packageInfo.version}" + val descriptor = getDescriptor(node) + return "$SCHEME $packagePart $parentDescriptors$descriptor" + } + + /** + * Get SCIP descriptor for a node following SCIP grammar: ::= '#' ::= + * '.' ::= '(' ()? ').' ::= '/' + */ + fun getDescriptor(node: PklNode): String = + when (node) { + is PklModule -> { + val moduleName = getModuleName(node) + "${ScipCanonicalizer.canonicalizeIdentifier(moduleName)}/" // namespace + } + is PklClass -> "${ScipCanonicalizer.canonicalizeIdentifier(node.name)}#" // type + is PklTypeAlias -> "${ScipCanonicalizer.canonicalizeIdentifier(node.name)}#" // type + is PklClassMethod -> "${ScipCanonicalizer.canonicalizeIdentifier(node.name)}()." // method + is PklObjectMethod -> "${ScipCanonicalizer.canonicalizeIdentifier(node.name)}()." // method + is PklClassProperty -> "${ScipCanonicalizer.canonicalizeIdentifier(node.name)}." // term + is PklObjectProperty -> "${ScipCanonicalizer.canonicalizeIdentifier(node.name)}." // term + else -> "${getNodeName(node)}." // default to term + } + + // Module names aren't unique identifiers, so we derive a name from the URI instead + private fun getModuleName(module: PklModule): String { + // Special handling for stdlib + if (module.uri.toString().startsWith("pkl:")) { + return module.moduleName!! + } + + val filePath = module.containingFile.path.toString() + val projectDir = module.containingFile.pklProjectDir?.path?.toString() + + return if (projectDir != null) { + // Module is part of a project directory + filePath.removePrefix(projectDir).removePrefix("/") + } else { + // Project Dir can be null. Use the rootPath as fallback + val rootPathStr = rootPath.toString() + if (filePath.startsWith(rootPathStr)) { + filePath.removePrefix(rootPathStr).removePrefix("/") + } else { + // If file is not under root path just return file path. It's likely part of a package + filePath.removePrefix("/") + } + } + } + + private fun getNodeName(node: PklNode): String = + when (node) { + is PklNamedNode -> ScipCanonicalizer.canonicalizeIdentifier(node.name) + else -> + ScipCanonicalizer.canonicalizeIdentifier(node.text.take(50).replace(Regex("\\s+"), "_")) + } + + /** + * Generate local symbol for document-local entities. All symbols are automatically canonicalized. + */ + fun formatLocalSymbol(name: String, span: Span): String { + val canonicalId = ScipCanonicalizer.canonicalizeIdentifier("${name}_${span.beginLine}") + return "local $canonicalId" + } + + /** + * Generate external symbol reference (for built-in types, stdlib, etc.) All symbols are + * automatically canonicalized. + */ + fun formatExternalSymbol( + scheme: String, + manager: String, + packageName: String, + version: String, + descriptor: String, + ): String { + // Apply unified canonicalization to the descriptor part + val canonicalDescriptor = ScipCanonicalizer.canonicalizeDescriptor(descriptor) + return "$scheme $manager $packageName $version $canonicalDescriptor" + } + + fun getSymbolKind(node: PklNode): SymbolInformation.Kind = + when (node) { + is PklModule -> SymbolInformation.Kind.Module + is PklClass -> SymbolInformation.Kind.Class + is PklClassMethod -> SymbolInformation.Kind.Method + is PklClassProperty -> SymbolInformation.Kind.Field + is PklTypeAlias -> SymbolInformation.Kind.Type + is PklObjectProperty -> SymbolInformation.Kind.Field + is PklObjectMethod -> SymbolInformation.Kind.Method + else -> SymbolInformation.Kind.UnspecifiedKind + } +} diff --git a/src/main/kotlin/org/pkl/lsp/util/PathUtils.kt b/src/main/kotlin/org/pkl/lsp/util/PathUtils.kt new file mode 100644 index 00000000..24785d1f --- /dev/null +++ b/src/main/kotlin/org/pkl/lsp/util/PathUtils.kt @@ -0,0 +1,86 @@ +/* + * Copyright © 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.pkl.lsp.util + +import java.nio.file.Path +import kotlin.io.path.* + +/** + * Utility functions for common path operations in the LSP implementation. + */ +object PathUtils { + + /** + * Finds the common root directory for a list of paths. + * Returns the deepest directory that contains all given paths. + */ + fun findCommonRoot(paths: List): Path { + if (paths.isEmpty()) return Path.of("") + if (paths.size == 1) return paths[0] ?: Path.of("") + + // Remove empty paths, and make the rest absolute + val absolutePaths = paths.filter { it.toString() != "" }.map { it.toAbsolutePath() } + var commonRoot = absolutePaths[0] ?: return Path.of("") + + for (path in absolutePaths.drop(1)) { + while (!path.startsWith(commonRoot)) { + commonRoot = commonRoot.parent ?: return Path.of("") + } + } + + return commonRoot + } + + /** + * Finds all Pkl files (*.pkl and PklProject files) recursively in the given roots. + * Handles both individual files and directories. + */ + fun findPklFiles(roots: List): List { + return roots.flatMap { root -> + when { + root.isRegularFile() && root.extension == "pkl" -> listOf(root) + root.isDirectory() -> { + @OptIn(ExperimentalPathApi::class) + root + .walk() + .filter { + it.isRegularFile() && (it.extension == "pkl" || it.fileName.name == "PklProject") + } + .toList() + } + else -> emptyList() + } + } + } + + /** + * Safely converts a path to absolute path with proper error handling. + */ + fun Path.toAbsolutePathSafe(): Path = try { + toAbsolutePath() + } catch (e: Exception) { + this + } + + /** + * Safely converts a path to real path (resolving symlinks) with proper error handling. + */ + fun Path.toRealPathSafe(): Path = try { + toRealPath() + } catch (e: Exception) { + toAbsolutePathSafe() + } +} \ No newline at end of file diff --git a/src/main/proto/scip.proto b/src/main/proto/scip.proto new file mode 100644 index 00000000..d21d0b23 --- /dev/null +++ b/src/main/proto/scip.proto @@ -0,0 +1,885 @@ +// An index contains one or more pieces of information about a given piece of +// source code or software artifact. Complementary information can be merged +// together from multiple sources to provide a unified code intelligence +// experience. +// +// Programs producing a file of this format is an "indexer" and may operate +// somewhere on the spectrum between precision, such as indexes produced by +// compiler-backed indexers, and heurstics, such as indexes produced by local +// syntax-directed analysis for scope rules. + +syntax = "proto3"; + +package scip; + +option go_package = "github.com/sourcegraph/scip/bindings/go/scip/"; + +// Index represents a complete SCIP index for a workspace this is rooted at a +// single directory. An Index message payload can have a large memory footprint +// and it's therefore recommended to emit and consume an Index payload one field +// value at a time. To permit streaming consumption of an Index payload, the +// `metadata` field must appear at the start of the stream and must only appear +// once in the stream. Other field values may appear in any order. +message Index { + // Metadata about this index. + Metadata metadata = 1; + // Documents that belong to this index. + repeated Document documents = 2; + // (optional) Symbols that are referenced from this index but are defined in + // an external package (a separate `Index` message). Leave this field empty + // if you assume the external package will get indexed separately. If the + // external package won't get indexed for some reason then you can use this + // field to provide hover documentation for those external symbols. + repeated SymbolInformation external_symbols = 3; + // IMPORTANT: When adding a new field to `Index` here, add a matching + // function in `IndexVisitor` and update `ParseStreaming`. +} + +message Metadata { + // Which version of this protocol was used to generate this index? + ProtocolVersion version = 1; + // Information about the tool that produced this index. + ToolInfo tool_info = 2; + // URI-encoded absolute path to the root directory of this index. All + // documents in this index must appear in a subdirectory of this root + // directory. + string project_root = 3; + // Text encoding of the source files on disk that are referenced from + // `Document.relative_path`. This value is unrelated to the `Document.text` + // field, which is a Protobuf string and hence must be UTF-8 encoded. + TextEncoding text_document_encoding = 4; +} + +enum ProtocolVersion { + UnspecifiedProtocolVersion = 0; +} + +enum TextEncoding { + UnspecifiedTextEncoding = 0; + UTF8 = 1; + UTF16 = 2; +} + +message ToolInfo { + // Name of the indexer that produced this index. + string name = 1; + // Version of the indexer that produced this index. + string version = 2; + // Command-line arguments that were used to invoke this indexer. + repeated string arguments = 3; +} + +// Document defines the metadata about a source file on disk. +message Document { + // The string ID for the programming language this file is written in. + // The `Language` enum contains the names of most common programming languages. + // This field is typed as a string to permit any programming language, including + // ones that are not specified by the `Language` enum. + string language = 4; + // (Required) Unique path to the text document. + // + // 1. The path must be relative to the directory supplied in the associated + // `Metadata.project_root`. + // 2. The path must not begin with a leading '/'. + // 3. The path must point to a regular file, not a symbolic link. + // 4. The path must use '/' as the separator, including on Windows. + // 5. The path must be canonical; it cannot include empty components ('//'), + // or '.' or '..'. + string relative_path = 1; + // Occurrences that appear in this file. + repeated Occurrence occurrences = 2; + // Symbols that are "defined" within this document. + // + // This should include symbols which technically do not have any definition, + // but have a reference and are defined by some other symbol (see + // Relationship.is_definition). + repeated SymbolInformation symbols = 3; + + // (optional) Text contents of the this document. Indexers are not expected to + // include the text by default. It's preferrable that clients read the text + // contents from the file system by resolving the absolute path from joining + // `Index.metadata.project_root` and `Document.relative_path`. This field was + // introduced to support `SymbolInformation.signature_documentation`, but it + // can be used for other purposes as well, for example testing or when working + // with virtual/in-memory documents. + string text = 5; + + // Specifies the encoding used for source ranges in this Document. + // + // Usually, this will match the type used to index the string type + // in the indexer's implementation language in O(1) time. + // - For an indexer implemented in JVM/.NET language or JavaScript/TypeScript, + // use UTF16CodeUnitOffsetFromLineStart. + // - For an indexer implemented in Python, + // use UTF32CodeUnitOffsetFromLineStart. + // - For an indexer implemented in Go, Rust or C++, + // use UTF8ByteOffsetFromLineStart. + PositionEncoding position_encoding = 6; +} + +// Encoding used to interpret the 'character' value in source ranges. +enum PositionEncoding { + // Default value. This value should not be used by new SCIP indexers + // so that a consumer can process the SCIP index without ambiguity. + UnspecifiedPositionEncoding = 0; + // The 'character' value is interpreted as an offset in terms + // of UTF-8 code units (i.e. bytes). + // + // Example: For the string "🚀 Woo" in UTF-8, the bytes are + // [240, 159, 154, 128, 32, 87, 111, 111], so the offset for 'W' + // would be 5. + UTF8CodeUnitOffsetFromLineStart = 1; + // The 'character' value is interpreted as an offset in terms + // of UTF-16 code units (each is 2 bytes). + // + // Example: For the string "🚀 Woo", the UTF-16 code units are + // ['\ud83d', '\ude80', ' ', 'W', 'o', 'o'], so the offset for 'W' + // would be 3. + UTF16CodeUnitOffsetFromLineStart = 2; + // The 'character' value is interpreted as an offset in terms + // of UTF-32 code units (each is 4 bytes). + // + // Example: For the string "🚀 Woo", the UTF-32 code units are + // ['🚀', ' ', 'W', 'o', 'o'], so the offset for 'W' would be 2. + UTF32CodeUnitOffsetFromLineStart = 3; +} + +// Symbol is similar to a URI, it identifies a class, method, or a local +// variable. `SymbolInformation` contains rich metadata about symbols such as +// the docstring. +// +// Symbol has a standardized string representation, which can be used +// interchangeably with `Symbol`. The syntax for Symbol is the following: +// ``` +// # ()+ stands for one or more repetitions of +// # ()? stands for zero or one occurrence of +// ::= ' ' ' ' ()+ | 'local ' +// ::= ' ' ' ' +// ::= any UTF-8, escape spaces with double space. Must not be empty nor start with 'local' +// ::= any UTF-8, escape spaces with double space. Use the placeholder '.' to indicate an empty value +// ::= same as above +// ::= same as above +// ::= | | | | | | | +// ::= '/' +// ::= '#' +// ::= '.' +// ::= ':' +// ::= '!' +// ::= '(' ()? ').' +// ::= '[' ']' +// ::= '(' ')' +// ::= +// ::= +// ::= | +// ::= ()+ +// ::= '_' | '+' | '-' | '$' | ASCII letter or digit +// ::= '`' ()+ '`', must contain at least one non- +// ::= any UTF-8, escape backticks with double backtick. +// ::= +// ``` +// +// The list of descriptors for a symbol should together form a fully +// qualified name for the symbol. That is, it should serve as a unique +// identifier across the package. Typically, it will include one descriptor +// for every node in the AST (along the ancestry path) between the root of +// the file and the node corresponding to the symbol. +// +// Local symbols MUST only be used for entities which are local to a Document, +// and cannot be accessed from outside the Document. +message Symbol { + string scheme = 1; + Package package = 2; + repeated Descriptor descriptors = 3; +} + +// Unit of packaging and distribution. +// +// NOTE: This corresponds to a module in Go and JVM languages. +message Package { + string manager = 1; + string name = 2; + string version = 3; +} + +message Descriptor { + enum Suffix { + option allow_alias = true; + UnspecifiedSuffix = 0; + // Unit of code abstraction and/or namespacing. + // + // NOTE: This corresponds to a package in Go and JVM languages. + Namespace = 1; + // Use Namespace instead. + Package = 1 [deprecated=true]; + Type = 2; + Term = 3; + Method = 4; + TypeParameter = 5; + Parameter = 6; + // Can be used for any purpose. + Meta = 7; + Local = 8; + Macro = 9; + } + string name = 1; + string disambiguator = 2; + Suffix suffix = 3; + // NOTE: If you add new fields here, make sure to update the prepareSlot() + // function responsible for parsing symbols. +} + +// SymbolInformation defines metadata about a symbol, such as the symbol's +// docstring or what package it's defined it. +message SymbolInformation { + // Identifier of this symbol, which can be referenced from `Occurence.symbol`. + // The string must be formatted according to the grammar in `Symbol`. + string symbol = 1; + // (optional, but strongly recommended) The markdown-formatted documentation + // for this symbol. Use `SymbolInformation.signature_documentation` to + // document the method/class/type signature of this symbol. + // Due to historical reasons, indexers may include signature documentation in + // this field by rendering markdown code blocks. New indexers should only + // include non-code documentation in this field, for example docstrings. + repeated string documentation = 3; + // (optional) Relationships to other symbols (e.g., implements, type definition). + repeated Relationship relationships = 4; + // The kind of this symbol. Use this field instead of + // `SymbolDescriptor.Suffix` to determine whether something is, for example, a + // class or a method. + Kind kind = 5; + // (optional) Kind represents the fine-grained category of a symbol, suitable for presenting + // information about the symbol's meaning in the language. + // + // For example: + // - A Java method would have the kind `Method` while a Go function would + // have the kind `Function`, even if the symbols for these use the same + // syntax for the descriptor `SymbolDescriptor.Suffix.Method`. + // - A Go struct has the symbol kind `Struct` while a Java class has + // the symbol kind `Class` even if they both have the same descriptor: + // `SymbolDescriptor.Suffix.Type`. + // + // Since Kind is more fine-grained than Suffix: + // - If two symbols have the same Kind, they should share the same Suffix. + // - If two symbols have different Suffixes, they should have different Kinds. + enum Kind { + UnspecifiedKind = 0; + // A method which may or may not have a body. For Java, Kotlin etc. + AbstractMethod = 66; + // For Ruby's attr_accessor + Accessor = 72; + Array = 1; + // For Alloy + Assertion = 2; + AssociatedType = 3; + // For C++ + Attribute = 4; + // For Lean + Axiom = 5; + Boolean = 6; + Class = 7; + // For C++ + Concept = 86; + Constant = 8; + Constructor = 9; + // For Solidity + Contract = 62; + // For Haskell + DataFamily = 10; + // For C# and F# + Delegate = 73; + Enum = 11; + EnumMember = 12; + Error = 63; + Event = 13; + // For Dart + Extension = 84; + // For Alloy + Fact = 14; + Field = 15; + File = 16; + Function = 17; + // For 'get' in Swift, 'attr_reader' in Ruby + Getter = 18; + // For Raku + Grammar = 19; + // For Purescript and Lean + Instance = 20; + Interface = 21; + Key = 22; + // For Racket + Lang = 23; + // For Lean + Lemma = 24; + // For solidity + Library = 64; + Macro = 25; + Method = 26; + // For Ruby + MethodAlias = 74; + // Analogous to 'ThisParameter' and 'SelfParameter', but for languages + // like Go where the receiver doesn't have a conventional name. + MethodReceiver = 27; + // Analogous to 'AbstractMethod', for Go. + MethodSpecification = 67; + // For Protobuf + Message = 28; + // For Dart + Mixin = 85; + // For Solidity + Modifier = 65; + Module = 29; + Namespace = 30; + Null = 31; + Number = 32; + Object = 33; + Operator = 34; + Package = 35; + PackageObject = 36; + Parameter = 37; + ParameterLabel = 38; + // For Haskell's PatternSynonyms + Pattern = 39; + // For Alloy + Predicate = 40; + Property = 41; + // Analogous to 'Trait' and 'TypeClass', for Swift and Objective-C + Protocol = 42; + // Analogous to 'AbstractMethod', for Swift and Objective-C. + ProtocolMethod = 68; + // Analogous to 'AbstractMethod', for C++. + PureVirtualMethod = 69; + // For Haskell + Quasiquoter = 43; + // 'self' in Python, Rust, Swift etc. + SelfParameter = 44; + // For 'set' in Swift, 'attr_writer' in Ruby + Setter = 45; + // For Alloy, analogous to 'Struct'. + Signature = 46; + // For Ruby + SingletonClass = 75; + // Analogous to 'StaticMethod', for Ruby. + SingletonMethod = 76; + // Analogous to 'StaticField', for C++ + StaticDataMember = 77; + // For C# + StaticEvent = 78; + // For C# + StaticField = 79; + // For Java, C#, C++ etc. + StaticMethod = 80; + // For C#, TypeScript etc. + StaticProperty = 81; + // For C, C++ + StaticVariable = 82; + String = 48; + Struct = 49; + // For Swift + Subscript = 47; + // For Lean + Tactic = 50; + // For Lean + Theorem = 51; + // Method receiver for languages + // 'this' in JavaScript, C++, Java etc. + ThisParameter = 52; + // Analogous to 'Protocol' and 'TypeClass', for Rust, Scala etc. + Trait = 53; + // Analogous to 'AbstractMethod', for Rust, Scala etc. + TraitMethod = 70; + // Data type definition for languages like OCaml which use `type` + // rather than separate keywords like `struct` and `enum`. + Type = 54; + TypeAlias = 55; + // Analogous to 'Trait' and 'Protocol', for Haskell, Purescript etc. + TypeClass = 56; + // Analogous to 'AbstractMethod', for Haskell, Purescript etc. + TypeClassMethod = 71; + // For Haskell + TypeFamily = 57; + TypeParameter = 58; + // For C, C++, Capn Proto + Union = 59; + Value = 60; + Variable = 61; + // Next = 87; + // Feel free to open a PR proposing new language-specific kinds. + } + // (optional) The name of this symbol as it should be displayed to the user. + // For example, the symbol "com/example/MyClass#myMethod(+1)." should have the + // display name "myMethod". The `symbol` field is not a reliable source of + // the display name for several reasons: + // + // - Local symbols don't encode the name. + // - Some languages have case-insensitive names, so the symbol is all-lowercase. + // - The symbol may encode names with special characters that should not be + // displayed to the user. + string display_name = 6; + // (optional) The signature of this symbol as it's displayed in API + // documentation or in hover tooltips. For example, a Java method that adds + // two numbers this would have `Document.language = "java"` and `Document.text + // = "void add(int a, int b)". The `language` and `text` fields are required + // while other fields such as `Documentation.occurrences` can be optionally + // included to support hyperlinking referenced symbols in the signature. + Document signature_documentation = 7; + // (optional) The enclosing symbol if this is a local symbol. For non-local + // symbols, the enclosing symbol should be parsed from the `symbol` field + // using the `Descriptor` grammar. + // + // The primary use-case for this field is to allow local symbol to be displayed + // in a symbol hierarchy for API documentation. It's OK to leave this field + // empty for local variables since local variables usually don't belong in API + // documentation. However, in the situation that you wish to include a local + // symbol in the hierarchy, then you can use `enclosing_symbol` to locate the + // "parent" or "owner" of this local symbol. For example, a Java indexer may + // choose to use local symbols for private class fields while providing an + // `enclosing_symbol` to reference the enclosing class to allow the field to + // be part of the class documentation hierarchy. From the perspective of an + // author of an indexer, the decision to use a local symbol or global symbol + // should exclusively be determined whether the local symbol is accessible + // outside the document, not by the capability to find the enclosing + // symbol. + string enclosing_symbol = 8; +} + + +message Relationship { + string symbol = 1; + // When resolving "Find references", this field documents what other symbols + // should be included together with this symbol. For example, consider the + // following TypeScript code that defines two symbols `Animal#sound()` and + // `Dog#sound()`: + // ```ts + // interface Animal { + // ^^^^^^ definition Animal# + // sound(): string + // ^^^^^ definition Animal#sound() + // } + // class Dog implements Animal { + // ^^^ definition Dog#, relationships = [{symbol: "Animal#", is_implementation: true}] + // public sound(): string { return "woof" } + // ^^^^^ definition Dog#sound(), references_symbols = Animal#sound(), relationships = [{symbol: "Animal#sound()", is_implementation:true, is_reference: true}] + // } + // const animal: Animal = new Dog() + // ^^^^^^ reference Animal# + // console.log(animal.sound()) + // ^^^^^ reference Animal#sound() + // ``` + // Doing "Find references" on the symbol `Animal#sound()` should return + // references to the `Dog#sound()` method as well. Vice-versa, doing "Find + // references" on the `Dog#sound()` method should include references to the + // `Animal#sound()` method as well. + bool is_reference = 2; + // Similar to `is_reference` but for "Find implementations". + // It's common for `is_implementation` and `is_reference` to both be true but + // it's not always the case. + // In the TypeScript example above, observe that `Dog#` has an + // `is_implementation` relationship with `"Animal#"` but not `is_reference`. + // This is because "Find references" on the "Animal#" symbol should not return + // "Dog#". We only want "Dog#" to return as a result for "Find + // implementations" on the "Animal#" symbol. + bool is_implementation = 3; + // Similar to `references_symbols` but for "Go to type definition". + bool is_type_definition = 4; + // Allows overriding the behavior of "Go to definition" and "Find references" + // for symbols which do not have a definition of their own or could + // potentially have multiple definitions. + // + // For example, in a language with single inheritance and no field overriding, + // inherited fields can reuse the same symbol as the ancestor which declares + // the field. In such a situation, is_definition is not needed. + // + // On the other hand, in languages with single inheritance and some form + // of mixins, you can use is_definition to relate the symbol to the + // matching symbol in ancestor classes, and is_reference to relate the + // symbol to the matching symbol in mixins. + // + // NOTE: At the moment, due to limitations of the SCIP to LSIF conversion, + // only global symbols in an index are allowed to use is_definition. + // The relationship may not get recorded if either symbol is local. + bool is_definition = 5; + // Update registerInverseRelationships on adding a new field here. +} + +// SymbolRole declares what "role" a symbol has in an occurrence. A role is +// encoded as a bitset where each bit represents a different role. For example, +// to determine if the `Import` role is set, test whether the second bit of the +// enum value is defined. In pseudocode, this can be implemented with the +// logic: `const isImportRole = (role.value & SymbolRole.Import.value) > 0`. +enum SymbolRole { + // This case is not meant to be used; it only exists to avoid an error + // from the Protobuf code generator. + UnspecifiedSymbolRole = 0; + // Is the symbol defined here? If not, then this is a symbol reference. + Definition = 0x1; + // Is the symbol imported here? + Import = 0x2; + // Is the symbol written here? + WriteAccess = 0x4; + // Is the symbol read here? + ReadAccess = 0x8; + // Is the symbol in generated code? + Generated = 0x10; + // Is the symbol in test code? + Test = 0x20; + // Is this a signature for a symbol that is defined elsewhere? + // + // Applies to forward declarations for languages like C, C++ + // and Objective-C, as well as `val` declarations in interface + // files in languages like SML and OCaml. + ForwardDefinition = 0x40; +} + +enum SyntaxKind { + option allow_alias = true; + + UnspecifiedSyntaxKind = 0; + + // Comment, including comment markers and text + Comment = 1; + + // `;` `.` `,` + PunctuationDelimiter = 2; + // (), {}, [] when used syntactically + PunctuationBracket = 3; + + // `if`, `else`, `return`, `class`, etc. + Keyword = 4; + IdentifierKeyword = 4 [deprecated=true]; + + // `+`, `*`, etc. + IdentifierOperator = 5; + + // non-specific catch-all for any identifier not better described elsewhere + Identifier = 6; + // Identifiers builtin to the language: `min`, `print` in Python. + IdentifierBuiltin = 7; + // Identifiers representing `null`-like values: `None` in Python, `nil` in Go. + IdentifierNull = 8; + // `xyz` in `const xyz = "hello"` + IdentifierConstant = 9; + // `var X = "hello"` in Go + IdentifierMutableGlobal = 10; + // Parameter definition and references + IdentifierParameter = 11; + // Identifiers for variable definitions and references within a local scope + IdentifierLocal = 12; + // Identifiers that shadow other identifiers in an outer scope + IdentifierShadowed = 13; + // Identifier representing a unit of code abstraction and/or namespacing. + // + // NOTE: This corresponds to a package in Go and JVM languages, + // and a module in languages like Python and JavaScript. + IdentifierNamespace = 14; + IdentifierModule = 14 [deprecated=true]; + + // Function references, including calls + IdentifierFunction = 15; + // Function definition only + IdentifierFunctionDefinition = 16; + + // Macro references, including invocations + IdentifierMacro = 17; + // Macro definition only + IdentifierMacroDefinition = 18; + + // non-builtin types + IdentifierType = 19; + // builtin types only, such as `str` for Python or `int` in Go + IdentifierBuiltinType = 20; + + // Python decorators, c-like __attribute__ + IdentifierAttribute = 21; + + // `\b` + RegexEscape = 22; + // `*`, `+` + RegexRepeated = 23; + // `.` + RegexWildcard = 24; + // `(`, `)`, `[`, `]` + RegexDelimiter = 25; + // `|`, `-` + RegexJoin = 26; + + // Literal strings: "Hello, world!" + StringLiteral = 27; + // non-regex escapes: "\t", "\n" + StringLiteralEscape = 28; + // datetimes within strings, special words within a string, `{}` in format strings + StringLiteralSpecial = 29; + // "key" in { "key": "value" }, useful for example in JSON + StringLiteralKey = 30; + // 'c' or similar, in languages that differentiate strings and characters + CharacterLiteral = 31; + // Literal numbers, both floats and integers + NumericLiteral = 32; + // `true`, `false` + BooleanLiteral = 33; + + // Used for XML-like tags + Tag = 34; + // Attribute name in XML-like tags + TagAttribute = 35; + // Delimiters for XML-like tags + TagDelimiter = 36; +} + +// Occurrence associates a source position with a symbol and/or highlighting +// information. +// +// If possible, indexers should try to bundle logically related information +// across occurrences into a single occurrence to reduce payload sizes. +message Occurrence { + // Half-open [start, end) range of this occurrence. Must be exactly three or four + // elements: + // + // - Four elements: `[startLine, startCharacter, endLine, endCharacter]` + // - Three elements: `[startLine, startCharacter, endCharacter]`. The end line + // is inferred to have the same value as the start line. + // + // It is allowed for the range to be empty (i.e. start==end). + // + // Line numbers and characters are always 0-based. Make sure to increment the + // line/character values before displaying them in an editor-like UI because + // editors conventionally use 1-based numbers. + // + // The 'character' value is interpreted based on the PositionEncoding for + // the Document. + // + // Historical note: the original draft of this schema had a `Range` message + // type with `start` and `end` fields of type `Position`, mirroring LSP. + // Benchmarks revealed that this encoding was inefficient and that we could + // reduce the total payload size of an index by 50% by using `repeated int32` + // instead. The `repeated int32` encoding is admittedly more embarrassing to + // work with in some programming languages but we hope the performance + // improvements make up for it. + repeated int32 range = 1; + // (optional) The symbol that appears at this position. See + // `SymbolInformation.symbol` for how to format symbols as strings. + string symbol = 2; + // (optional) Bitset containing `SymbolRole`s in this occurrence. + // See `SymbolRole`'s documentation for how to read and write this field. + int32 symbol_roles = 3; + // (optional) CommonMark-formatted documentation for this specific range. If + // empty, the `Symbol.documentation` field is used instead. One example + // where this field might be useful is when the symbol represents a generic + // function (with abstract type parameters such as `List`) and at this + // occurrence we know the exact values (such as `List`). + // + // This field can also be used for dynamically or gradually typed languages, + // which commonly allow for type-changing assignment. + repeated string override_documentation = 4; + // (optional) What syntax highlighting class should be used for this range? + SyntaxKind syntax_kind = 5; + // (optional) Diagnostics that have been reported for this specific range. + repeated Diagnostic diagnostics = 6; + // (optional) Using the same encoding as the sibling `range` field, half-open + // source range of the nearest non-trivial enclosing AST node. This range must + // enclose the `range` field. Example applications that make use of the + // enclosing_range field: + // + // - Call hierarchies: to determine what symbols are references from the body + // of a function + // - Symbol outline: to display breadcrumbs from the cursor position to the + // root of the file + // - Expand selection: to select the nearest enclosing AST node. + // - Highlight range: to indicate the AST expression that is associated with a + // hover popover + // + // For definition occurrences, the enclosing range should indicate the + // start/end bounds of the entire definition AST node, including + // documentation. + // ``` + // const n = 3 + // ^ range + // ^^^^^^^^^^^ enclosing_range + // + // /** Parses the string into something */ + // ^ enclosing_range start --------------------------------------| + // function parse(input string): string { | + // ^^^^^ range | + // return input.slice(n) | + // } | + // ^ enclosing_range end <---------------------------------------| + // ``` + // + // Any attributes/decorators/attached macros should also be part of the + // enclosing range. + // + // ```python + // @cache + // ^ enclosing_range start---------------------| + // def factorial(n): | + // return n * factorial(n-1) if n else 1 | + // < enclosing_range end-----------------------| + // + // ``` + // + // For reference occurrences, the enclosing range should indicate the start/end + // bounds of the parent expression. + // ``` + // const a = a.b + // ^ range + // ^^^ enclosing_range + // const b = a.b(41).f(42).g(43) + // ^ range + // ^^^^^^^^^^^^^ enclosing_range + // ``` + repeated int32 enclosing_range = 7; +} + +// Represents a diagnostic, such as a compiler error or warning, which should be +// reported for a document. +message Diagnostic { + // Should this diagnostic be reported as an error, warning, info, or hint? + Severity severity = 1; + // (optional) Code of this diagnostic, which might appear in the user interface. + string code = 2; + // Message of this diagnostic. + string message = 3; + // (optional) Human-readable string describing the source of this diagnostic, e.g. + // 'typescript' or 'super lint'. + string source = 4; + repeated DiagnosticTag tags = 5; +} + +enum Severity { + UnspecifiedSeverity = 0; + Error = 1; + Warning = 2; + Information = 3; + Hint = 4; +} + +enum DiagnosticTag { + UnspecifiedDiagnosticTag = 0; + Unnecessary = 1; + Deprecated = 2; +} + +// Language standardises names of common programming languages that can be used +// for the `Document.language` field. The primary purpose of this enum is to +// prevent a situation where we have a single programming language ends up with +// multiple string representations. For example, the C++ language uses the name +// "CPP" in this enum and other names such as "cpp" are incompatible. +// Feel free to send a pull-request to add missing programming languages. +enum Language { + UnspecifiedLanguage = 0; + ABAP = 60; + Apex = 96; + APL = 49; + Ada = 39; + Agda = 45; + AsciiDoc = 86; + Assembly = 58; + Awk = 66; + Bat = 68; + BibTeX = 81; + C = 34; + COBOL = 59; + CPP = 35; // C++ (the name "CPP" was chosen for consistency with LSP) + CSS = 26; + CSharp = 1; + Clojure = 8; + Coffeescript = 21; + CommonLisp = 9; + Coq = 47; + CUDA = 97; + Dart = 3; + Delphi = 57; + Diff = 88; + Dockerfile = 80; + Dyalog = 50; + Elixir = 17; + Erlang = 18; + FSharp = 42; + Fish = 65; + Flow = 24; + Fortran = 56; + Git_Commit = 91; + Git_Config = 89; + Git_Rebase = 92; + Go = 33; + GraphQL = 98; + Groovy = 7; + HTML = 30; + Hack = 20; + Handlebars = 90; + Haskell = 44; + Idris = 46; + Ini = 72; + J = 51; + JSON = 75; + Java = 6; + JavaScript = 22; + JavaScriptReact = 93; + Jsonnet = 76; + Julia = 55; + Justfile = 109; + Kotlin = 4; + LaTeX = 83; + Lean = 48; + Less = 27; + Lua = 12; + Luau = 108; + Makefile = 79; + Markdown = 84; + Matlab = 52; + Nickel = 110; // https://nickel-lang.org/ + Nix = 77; + OCaml = 41; + Objective_C = 36; + Objective_CPP = 37; + Pascal = 99; + PHP = 19; + PLSQL = 70; + Perl = 13; + PowerShell = 67; + Prolog = 71; + Protobuf = 100; + Python = 15; + R = 54; + Racket = 11; + Raku = 14; + Razor = 62; + Repro = 102; // Internal language for testing SCIP + ReST = 85; + Ruby = 16; + Rust = 40; + SAS = 61; + SCSS = 29; + SML = 43; + SQL = 69; + Sass = 28; + Scala = 5; + Scheme = 10; + ShellScript = 64; // Bash + Skylark = 78; + Slang = 107; + Solidity = 95; + Svelte = 106; + Swift = 2; + Tcl = 101; + TOML = 73; + TeX = 82; + Thrift = 103; + TypeScript = 23; + TypeScriptReact = 94; + Verilog = 104; + VHDL = 105; + VisualBasic = 63; + Vue = 25; + Wolfram = 53; + XML = 31; + XSL = 32; + YAML = 74; + Zig = 38; + // NextLanguage = 111; + // Steps add a new language: + // 1. Copy-paste the "NextLanguage = N" line above + // 2. Increment "NextLanguage = N" to "NextLanguage = N+1" + // 3. Replace "NextLanguage = N" with the name of the new language. + // 4. Move the new language to the correct line above using alphabetical order + // 5. (optional) Add a brief comment behind the language if the name is not self-explanatory +}