open-index/open-npm huggingface dataset:
npm package: @immediate-diagram/cli
Description: Command-line tool for rendering, validating, previewing, and generating Immediate Diagram `.imd` files.
Latest version: 1.2.3

# @immediate-diagram/cli

Command-line tool for rendering, validating, previewing, and generating Immediate Diagram `.imd` files.

## Install

```bash
bun add -g @immediate-diagram/cli
```

> **Note:** This package publishes raw `.ts` source. Requires [Bun](https://bun.sh) as runtime.

## Commands

### `imd render`

Render an `.imd` file to SVG or PNG.

```bash
imd render input.imd                    # Output SVG to stdout
imd render input.imd -o output.svg      # Write to file
imd render input.imd -o output.png      # Render as PNG (via resvg)
imd render input.imd --state active     # Render a specific state
imd render input.imd --theme dark       # Use dark theme
```

### `imd validate`

Validate an `.imd` file (parse + semantic checks).

```bash
imd validate input.imd                  # Exit 0 if valid, 1 if errors
imd validate input.imd --recovery       # Show all errors (not just first)
```

### `imd preview`

Open a live preview in the browser with hot-reload.

```bash
imd preview input.imd                   # Open browser preview
imd preview input.imd --port 8080       # Custom port
```

The preview supports playback controls for diagrams with `@timeline`: play/pause, step forward/back, scrub, speed control, and loop toggle.

### `imd generate`

Generate a diagram from a natural-language prompt using an LLM.

```bash
imd generate "user login flow with email and OAuth"
imd generate "microservice architecture with 3 services" -o arch.imd
```

Requires `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` environment variable.

## Examples

```bash
# Render a flowchart to SVG
imd render examples/flowchart.imd -o flowchart.svg

# Validate all .imd files in a directory
for f in examples/*.imd; do imd validate "$f"; done

# Preview with live reload
imd preview examples/architecture.imd

# Generate from prompt
imd generate "CI/CD pipeline with build, test, deploy stages"
```

## Development

```bash
bun run dev         # Run CLI in dev mode
bun test            # Run tests
bun run typecheck   # Type checking
```

## License

MIT
npm package: @immediate-diagram/lsp-server
Description: Language Server Protocol (LSP) server for Immediate Diagram `.imd` files. Provides IDE features powered by the `@immediate-diagram/parser`.
Latest version: 1.2.3

# @immediate-diagram/lsp-server

Language Server Protocol (LSP) server for Immediate Diagram `.imd` files. Provides IDE features powered by the `@immediate-diagram/parser`.

## Install

```bash
bun add @immediate-diagram/lsp-server
```

> **Note:** This package publishes raw `.ts` source. Requires [Bun](https://bun.sh) as runtime.

## Features

- **Diagnostics** — real-time parse errors and semantic validation warnings
- **Autocomplete** — keyword completions for diagram types, directives, shapes, styles, and more
- **Hover** — documentation on hover for keywords, properties, and syntax
- **Document Symbols** — outline view with diagram structure (nodes, edges, states, groups)

## Usage

The LSP server is typically consumed by an editor extension (e.g., the [Immediate Diagram VS Code extension](../vscode-extension)).

### Standalone Usage

```typescript
import { getDiagnostics } from "@immediate-diagram/lsp-server";
import { getCompletionItems } from "@immediate-diagram/lsp-server";
import { getHoverInfo } from "@immediate-diagram/lsp-server";
import { getDocumentSymbols } from "@immediate-diagram/lsp-server";
```

### `getDiagnostics(text: string)`

Parse and validate the document, returning LSP `Diagnostic[]` for errors and warnings.

### `getCompletionItems(text: string, position: Position)`

Return context-aware completion items based on cursor position — diagram types, directives, node shapes, style properties, colors, easing functions.

### `getHoverInfo(text: string, position: Position)`

Return hover documentation for the token at the cursor position.

### `getDocumentSymbols(text: string)`

Return `DocumentSymbol[]` representing the document outline — diagram type, title, nodes, edges, states, groups.

## Development

```bash
bun test            # Run tests
bun run typecheck   # Type checking
```

## License

MIT
npm package: @immediate-diagram/shared
Description: Shared types, constants, and utilities used across all `@immediate-diagram` packages. Zero runtime dependencies.
Latest version: 1.2.3

# @immediate-diagram/shared

Shared types, constants, and utilities used across all `@immediate-diagram` packages. Zero runtime dependencies.

## Install

```bash
bun add @immediate-diagram/shared
```

> **Note:** This package publishes raw `.ts` source. Requires [Bun](https://bun.sh) as runtime.

## What's Included

### AST Types

Full TypeScript type definitions for the Immediate Diagram AST — `Document`, `NodeDeclaration`, `EdgeStatement`, `StateBlock`, `StyleBlock`, `TimelineBlock`, and all diagram-specific constructs.

```typescript
import type { Document, NodeDeclaration, EdgeStatement } from "@immediate-diagram/shared";
```

### Diagram Types (Discriminated Unions)

Narrowed diagram types for type-safe handling of each diagram kind:

```typescript
import type {
  FlowchartDiagram,
  SequenceDiagram,
  ArchitectureDiagram,
  PieDiagram,
  BlockDiagram,
  VennDiagram,
} from "@immediate-diagram/shared";

import { narrowDiagram } from "@immediate-diagram/shared";

// Narrows a parsed Document into a specific diagram type
const diagram = narrowDiagram(doc);
if (diagram.type === "flowchart") {
  diagram.nodes;  // FlowchartDiagram-specific
  diagram.edges;
}
```

### Positioned Types

Layout output types used by the renderer — `PositionedDiagram`, `PositionedNode`, `PositionedEdge`, and diagram-specific positioned types.

```typescript
import type { PositionedDiagram, PositionedNode, PositionedEdge } from "@immediate-diagram/shared";
```

### Theme System

Theme definitions, defaults, and resolution:

```typescript
import { DEFAULT_LIGHT_THEME, DEFAULT_DARK_THEME } from "@immediate-diagram/shared";
import type { DiagramTheme } from "@immediate-diagram/shared";
```

### Complexity Validation

Per-diagram-type complexity limits for resource protection:

```typescript
import { validateDiagramComplexity, DIAGRAM_TYPE_LIMITS } from "@immediate-diagram/shared";

const violations = validateDiagramComplexity(doc);
if (violations.length > 0) {
  console.error("Diagram too complex:", violations);
}
```

### Utilities

- `generateId()` — short random IDs
- `CircuitBreaker` — circuit breaker pattern for external service calls
- `inferTimelineDefinition()` — infer timeline from state/transition blocks
- State property classification (`LAYOUT_AFFECTING_PROPERTIES`, `STYLE_ONLY_PROPERTIES`)

## Development

```bash
bun test        # Run tests
bun run typecheck   # Type checking
```

## License

MIT
npm package: @immers-space/oauth2orize-jwt-bearer
Description: JSON Web Token (JWT) Bearer Token Exchange Middleware for OAuth2orize.
Author: bendiy
Latest version: 0.2.1

oauth2orize-jwt-bearer
======================

JSON Web Token (JWT) Bearer Token Exchange Middleware for [OAuth2orize](https://github.com/jaredhanson/oauth2orize).

This module exchanges a JWT for an access token after authenticated, as [defined](http://tools.ietf.org/html/draft-jones-oauth-jwt-bearer-01#section-2.1) by the JSON Web Token (JWT) Bearer Token Profiles for OAuth 2.0 draft.  This module is modeled off of Google's OAuth 2.0 [Server to Server Applications](https://developers.google.com/accounts/docs/OAuth2ServiceAccount).  This module can be used with the [passport-oauth2-jwt-bearer](https://github.com/xtuple/passport-oauth2-jwt-bearer) module to create a JWT OAuth 2.0 exchange scenario server.

## Install

    $ npm install oauth2orize-jwt-bearer

## Usage

#### Register Exchange Middleware

This exchange middleware is used to by clients to request an access token by using a JSON Web Token (JWT) generated by the client and verified by a Public Key stored on the OAuth 2.0 server.  The exchange requires a verify callback, which accepts the client, JWT data and signature, then calls done providing a access token. 

##### Key Generation Tips
generate private key
openssl genrsa -out private.pem 1024 

abstract public key
openssl rsa -in private.pem -out public.pem -outform PEM -pubout 

sign the data
signing data: echo -n "data-to-sign" | openssl dgst -RSA-SHA256 -sign private.pem > signed 

convert the signed file (binary) into base64 to be sent.
base64 signed

```javascript
var jwtBearer = require('oauth2orize-jwt-bearer').Exchange;

server.exchange('urn:ietf:params:oauth:grant-type:jwt-bearer', jwtBearer(function(client, data, signature, done) {
 var crypto = require('crypto')
   , fs = require('fs') //load file system so you can grab the public key to read.
   , pub = fs.readFileSync('/path/to/public.pem').toString() //load PEM format public key as string, should be clients public key
   , verifier = crypto.createVerify("RSA-SHA256");

 //verifier.update takes in a string of the data that is encrypted in the signature  
 verifier.update(JSON.stringify(data));

 if (verifier.verify(pub, signature, 'base64')) {
   //base64url decode data 
   var b64string = data;
   var buf = new Buffer(b64string, 'base64').toString('ascii');
 
   // TODO - verify client_id, scope and expiration are valid from the buf variable above

   AccessToken.create(client, scope, function(err, accessToken) {
     if (err) { return done(err); }
     done(null, accessToken);
   });
 }
}));
```

## Tests

    $ npm install --dev
    $ make test

## Credits

  - [bendiy](http://github.com/bendiy)

## License

[The MIT License](http://opensource.org/licenses/MIT)

Copyright (c) 2012-2013 xTuple <[http://www.xtuple.com/](http://www.xtuple.com/)>