topaz-js

Write, review, and debug Topaz JavaScript scripts running on the .NET runtime for EventService.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/D1ssolve/craft-agents --skill topaz-js-d1ssolve
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: topaz-js
Source: https://github.com/D1ssolve/craft-agents/tree/main/skills/topaz-js
Command: npx skills add https://github.com/D1ssolve/craft-agents --skill topaz-js-d1ssolve

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Topaz scripts use JavaScript syntax but execute on the .NET runtime, so standard JS built-ins like trim(), includes(), RegExp, and fetch() fail at runtime. This Skill prevents those errors by enforcing .NET PascalCase APIs, injected globals, and correct async patterns when writing or reviewing EventService scripts. ## Core Features & Use Cases - JS-to-.NET translation rules: Maps JavaScript built-ins to .NET equivalents such as Trim(), ToLower(), Split() with .Length, and Contains() instead of includes(). - Event handler templates: Provides ready structures for KafkaEvent consumers (no return value) and HttpRequestEvent handlers (must return HttpResponse). - Defensive patterns and checklist: Covers safe HTTP response handling with AsString() plus JSON.parse(), null-guards before DateTime.Parse(), correct Logger.LogError(error, ...) argument order, and a pre-delivery checklist of critical rules. - Use Case: A developer needs a script that consumes a Kafka message, calls an Agreement API via HttpClient, and produces a result event. The Skill supplies the correct async wrapper, error handling, and Producer.ProduceAsync() call without runtime-breaking JS idioms. ## Quick Start Write a Topaz script that handles a KafkaEvent, fetches agreement data over HTTP, and produces a processed event to a Kafka topic.

Frequently Asked Questions about topaz-js

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Topaz script for a KafkaEvent consumer?

Wrap the logic in an async function with try/catch, call it with await at the top level, and never return a value since Kafka consumers ignore returns. Use Logger.LogInformation for tracing and Logger.LogError with the exception as the first argument.

Why does str.trim() fail in Topaz scripts?

Topaz runs JavaScript syntax on the .NET runtime, so JS built-ins like trim(), toLowerCase(), and includes() do not exist. Use the .NET PascalCase equivalents: Trim(), ToLower(), and Contains().

Can I use RegExp or fetch() in Topaz JavaScript?

No. RegExp literals and fetch() are unsupported on the .NET runtime. Replace regex with IndexOf(), Contains(), StartsWith(), and Replace(), and use the injected HttpClient with Get, Post, PostJson, Patch, and Delete methods.

Why does AsJson() throw an exception on some HTTP responses?

AsJson() throws when the response body is empty, such as 204 responses. Always call AsString() first, check for empty content, and then parse with JSON.parse() to handle empty bodies safely.

What is the difference between KafkaEvent and HttpRequestEvent scripts in Topaz?

KafkaEvent consumers never return a value and use return only for early exit. HttpRequestEvent handlers must return a response at the top level, typically via return await handleRequest() with HttpResponse.Ok or HttpResponse.StatusCode.