2
0
Fork 0
mirror of https://github.com/Mallne/DC-Weaver.git synced 2026-11-22 20:43:03 +01:00
No description
  • Kotlin 96.7%
  • ANTLR 3.3%
Find a file
renovate[bot] aa9a85ac04
chore(deps): update dependency com.autonomousapps.dependency-analysis to v3.20.4 (#75)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-18 07:04:36 +00:00
.ai Add .ai/ documentation guides for multiple modules 2026-08-04 16:33:14 +02:00
.forgejo/workflows Add Actions workflows for PR checks, releases, and snapshots across multiple projects 2026-10-22 16:07:15 +02:00
.github/workflows fix(release): configure npm publication runtime and auth 2026-11-04 20:32:57 +01:00
core fix(build): honor NODE_HOME for npm publication 2026-11-04 20:41:49 +01:00
gradle chore(deps): update dependency com.autonomousapps.dependency-analysis to v3.20.4 (#75) 2026-11-18 07:04:36 +00:00
tokenizer fix(build): honor NODE_HOME for npm publication 2026-11-04 20:41:49 +01:00
.dockerignore Remove server module, translation-keys plugin, and update build configuration. 2025-07-15 15:23:36 +02:00
.gitignore Refactor and modularize Weaver AST and grammar definitions. 2025-07-20 13:16:24 +02:00
AGENTS.md Add .ai/ documentation guides for multiple modules 2026-08-04 16:33:14 +02:00
build.gradle.kts Use mise Node for package publishing 2026-10-22 15:46:07 +02:00
gradle.properties chore: bump version to 1.1.1-SNAPSHOT [skip ci] 2026-11-04 19:46:32 +00:00
gradlew fix: proper gradle wrapper, conditional signing, updated workflows 2026-09-19 10:10:51 +02:00
gradlew.bat fix: proper gradle wrapper, conditional signing, updated workflows 2026-09-19 10:10:51 +02:00
LICENSE Remove server module, translation-keys plugin, and update build configuration. 2025-07-15 15:23:36 +02:00
README.md Update Gradle build scripts and README for namespace and WOL details 2026-10-23 14:54:25 +02:00
renovate.json chore(ci): remove drone and teamcity from renovate auto-merge list 2026-11-17 12:27:14 +01:00
settings.gradle.kts fix: correct publishing, add ANTLR to CI, modernize renovate 2026-09-21 15:43:56 +02:00

DiCentra Weaver

DiCentra Kotlin License Kotlin Multiplatform

DiCentra Weaver is a schema-driven JSON transformation engine built with Kotlin Multiplatform. It uses the Weaver Object Language (WOL) to describe accessors, computations, and transformations across JVM, Android, iOS, JS, and Wasm targets.

Features

  • Schema-driven transformations: Define input-to-output mappings as reusable schemas and named transforms.
  • Weaver Object Language (WOL): Expressions for data access, computation, coercion, and transform invocation.
  • Kotlin Multiplatform: Share transformation logic across supported targets.
  • Extensible architecture: Add custom functions and plugins to an engine.

Installation

Kotlin Multiplatform

The Maven group is cloud.mallne.dicentra.weaver. Add the core dependency (which brings in the tokenizer) to build.gradle.kts; use the release version required by your project:

commonMain.dependencies {
    implementation("cloud.mallne.dicentra.weaver:core:1.0.1")
}

Resolve DiCentra artifacts from https://registry.mallne.cloud/repository/DiCentraArtefacts/ with registry credentials configured outside the build script.

JavaScript / TypeScript

Weaver publishes @dicentra/weaver-core (runtime) and @dicentra/weaver-tokenizer (WOL tokenizer/parser) to https://registry.mallne.cloud/repository/NodeRegistry/. The current release is 1.0.1. Configure the @dicentra npm scope and authenticate using NPM_TOKEN, then install the core package:

npm install @dicentra/weaver-core@1.0.1

The core package uses the tokenizer. Install @dicentra/weaver-tokenizer@1.0.1 directly only when using the parser independently.

Weaver Object Language (WOL)

WOL has accessor syntax for navigating input JSON and computation syntax for producing values. A transform declares the input accessor it runs against; inside its computation, {} denotes the current value. WOL is evaluated by Weaver at runtime, not by Kotlin.

Accessors and interpolation

Syntax Meaning
user.id Access the id field of user.
items[0] Access the first (zero-based) array element.
items[{##index##}] Access an array element using the numeric transform parameter index.
{#transform#} Reference/call a named transform.
{##param##} Access a named transform parameter.
` {value}

Accessor expressions used inside computations are wrapped in braces, for example {user.id}. A transform using items[{##index##}] declares index in its parameter map with type ObjectType.Number.

Computations

Category Examples
Arithmetic 1 + 2, ({price} * 10) / 2, 5 % 2
Boolean true && {isAdmin}, !{isBlocked}, `(5 > 2)
Comparison {age} >= 18, "admin" == {role}, 5 != 10
Ternary {score} > 50 ? "Pass" : "Fail"
Elvis {name} ?: "Anonymous"
Coercion `
Functions pow(2, 8), max({a}, {b})

The special expression |{}|ai| returns the current array's last valid zero-based index, or -1 when it is empty.

Kotlin schema builder DSL

The Kotlin DSL constructs schema declarations; expressions passed as strings remain WOL text and are evaluated by Weaver. A schema has one root, and each transform declares exactly one value, object, or array computation.

import cloud.mallne.dicentra.weaver.core.Weaver
import cloud.mallne.dicentra.weaver.core.specification.*
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put

val temperaturePath = Wol.path("current").field("temperature")
val schema = weaverSchema("weather-v1") {
    root("weather", Wol.reference("temperature"))
    transform("temperature", temperaturePath.asExpression()) {
        value("{}", ObjectType.Number) // `{}` reads the transform's current value
    }
}

val output = Weaver().engine(schema).executeElement(
    buildJsonObject { put("current", buildJsonObject { put("temperature", 18) }) },
)
// output is the JSON number 18

Use objectValue { ... } to build object output. Within it, property(name, expression) emits an expression verbatim, source(name, Wol.path(...), type) creates a source transform and property reference, and use(name, transform) references another named transform. Use array() for array output; its default item expression is {##value##} and its default iteration expression is |{}|ai|.

WolAccessorPath composes identifier-based accessors: Wol.path("items").index("index") produces items[{##index##}], while .element(0) produces items[0]. Wol.reference, Wol.stringLiteral, Wol.divide, Wol.multiply, and Wol.mapString construct common WOL snippets. WolIdentifier values must start with a letter or underscore and contain only letters, digits, or underscores.

Modules

  • core: Schema model, Kotlin DSL, execution engine, and runtime.
  • tokenizer: WOL tokenizer, lexer, and parser.

License

This project is licensed under the Apache License 2.0. See LICENSE for details.


Built with ❤️ by Mallne under the DiCentra umbrella