Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ContractTests/Client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/arc.core-client-contract",
"version": "0.50.0",
"version": "0.51.0",
"private": true,
"type": "module",
"dependencies": {
Expand Down
13 changes: 13 additions & 0 deletions ContractTests/Client/source-generation.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ export class Create { @fundamentals.field(Guid) id!: Guid; @field(Date) created!
}, include: ['Features/**/*.ts', 'interfaces/**/*.ts'] }));
const interfaceCompile = spawnSync(join(root, 'node_modules/.bin/tsc'), ['-p', join(src, 'tsconfig.json')], { cwd: root, encoding: 'utf8' });
assert.equal(interfaceCompile.status, 0, interfaceCompile.stdout + interfaceCompile.stderr);
const server = join(src, 'server'); await mkdir(server);
await generateFromSource({ project: join(src, 'tsconfig.json'), artifacts: features, output: server, skipReactHooks: true });
for (const name of ['Checkout/Create.ts', 'Listing/All.ts', 'Listing/Paged.ts', 'Listing/Stream.ts', 'Listing/Changes.ts'])
assert.doesNotMatch(await readFile(join(server, 'Shop', name), 'utf8'), /arc\.react|static use/);
await writeFile(join(src, 'tsconfig.json'), JSON.stringify({ compilerOptions: {
target: 'ES2022', module: 'ESNext', moduleResolution: 'Bundler', strict: true,
skipLibCheck: false, experimentalDecorators: true, noEmit: true, types: ['node']
}, include: ['Features/**/*.ts', 'server/**/*.ts'] }));
const serverCompile = spawnSync(join(root, 'node_modules/.bin/tsc'), ['-p', join(src, 'tsconfig.json'), '--listFilesOnly'], { cwd: root, encoding: 'utf8' });
assert.equal(serverCompile.status, 0, serverCompile.stdout + serverCompile.stderr);
// React must not be pulled into the program at all by server-only proxies.
assert.doesNotMatch(serverCompile.stdout, /arc\.react|node_modules\/(@types\/)?react\//);
});

test('edited generated barrels are not overwritten or deleted', async () => {
Expand Down Expand Up @@ -435,6 +447,7 @@ test('CLI accepts equals options, help, root namespace and safe output switches'
const help = spawnSync(process.execPath, [cli, '--help'], { cwd: root, encoding: 'utf8' });
assert.equal(help.status, 0, help.stderr);
assert.match(help.stdout, /--emit-interfaces/);
assert.match(help.stdout, /--skip-react-hooks/);
const generated = spawnSync(process.execPath, [cli, `--project=${project}`, `--artifacts=${artifacts}`, `--output=${output}`,
'--root-namespace=App', '--api-prefix=v2', '--use-generated-metadata', '--skip-index-generation', '--skip-output-deletion'], { cwd: root, encoding: 'utf8' });
assert.equal(generated.status, 0, generated.stderr);
Expand Down
2 changes: 1 addition & 1 deletion Documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Arc for TypeScript is a Node.js server implementation of [Arc](/arc/), the Crati
Without it, a Node.js backend for an Arc frontend means writing every route, request parser, validation response, and status code by hand, then keeping all of it in step with the frontend. With it, commands and queries run through one pipeline that owns those concerns, the wire behavior follows Arc on .NET, and the proxy generator writes the typed frontend client from your source.

:::caution[Source preview, no full parity]
No package is published to npm; the manifests are at version 0.50.0 for a source preview. Arc for TypeScript does **not** have full parity with Arc on .NET, and package names and APIs can still change. The [capability reference](reference/capabilities.md) is the single place for status and evidence.
No package is published to npm; the manifests are at version 0.51.0 for a source preview. Arc for TypeScript does **not** have full parity with Arc on .NET, and package names and APIs can still change. The [capability reference](reference/capabilities.md) is the single place for status and evidence.
:::

## What it looks like
Expand Down
1 change: 1 addition & 0 deletions Documentation/proxy-generation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Match these to the server's [endpoint mapping](../core/endpoint-mapping.md), or
| `--use-proxy-file-suffix` | Off for a dedicated output folder; required for co-located output | Name files `*.proxy.ts` instead of `*.ts` |
| `--js-import-specifiers` | Off | Use `.js` extensions in local imports, for native Node ESM; extensionless imports suit Vite and other bundlers |
| `--emit-interfaces` | Off | Emit undecorated interfaces instead of model classes; model constructors in proxies become `Object`, so choose this only when you do not need decorated model hydration |
| `--skip-react-hooks` | Off | Emit server-only proxies: no `@cratis/arc.react` import and no static `use*`/`when` hooks on commands and queries, so a project that only needs the typed HTTP client does not need React installed. The generated classes still work with `@cratis/arc` directly. Programmatic option: `skipReactHooks` |
| `--skip-index-generation` | Off for a dedicated output folder; automatic for co-located output | Do not write `index.ts` barrels |
| `--skip-output-deletion` | Off | Keep stale generated files instead of removing them |
| `--metadata <file>` | Off | Generate server artifact metadata at the given absolute path and infer undecorated bindings |
Expand Down
2 changes: 1 addition & 1 deletion Documentation/reference/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Packages
description: The packages this repository builds, what each exports, their peer dependencies and Node.js requirements, and how they relate to the published @cratis/arc client.
---

Every package in this repository is at version 0.50.0, the version of the source preview. **None is published to npm.** They ship ES modules only. Clone this repository, run `yarn install` and `yarn build`, and then use the packages in one of two ways:
Every package in this repository is at version 0.51.0, the version of the source preview. **None is published to npm.** They ship ES modules only. Clone this repository, run `yarn install` and `yarn build`, and then use the packages in one of two ways:

- **Inside the clone.** Put your application in a folder under `Samples/`, which the root `workspaces` list includes, and reference the packages with the `workspace:^` protocol, as [`Samples/Tasks/package.json`](https://github.com/Cratis/Arc.TypeScript/blob/main/Samples/Tasks/package.json) does. `workspace:^` resolves only inside this repository's Yarn workspace.
- **In your own project.** Pack each package you need with `yarn workspace <package> pack --out <file>` and install the tarballs with npm. Use `yarn pack`: it rewrites `workspace:^` dependencies to version ranges, and `npm pack` does not. `yarn check:consumers` installs packed packages this way to check NodeNext and Bundler consumers.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class TaskItem {
| `@cratis/arc.chronicle` | [`Source/Chronicle`](Source/Chronicle) | **Experimental.** `builder.withChronicle` appends returned events and resolves registered read models by command key; nested command returns join one event-log batch. In-memory command assertions are available under `@cratis/arc.chronicle/testing`. SDK 6.19.0 imports natively and infers read models from projections/reducers; an opt-in kernel suite covers aggregate replay and reactor commands. Full .NET transaction parity remains unverified. |
| `@cratis/cratis` | [`Source/Cratis`](Source/Cratis) | **Experimental source preview.** `CratisApplication.createBuilder()` and `builder.addCratis()` compose Arc and a Chronicle client without installing authentication; not yet published to npm. |

Every package manifest is at version 0.50.0. That is the version of this source preview, not an npm release, and the Chronicle package is experimental. The packages ship ES modules only, and schemas use Zod 4. The default core entry, host adapters, MongoDB, and Drizzle packages need Node.js 22 or later. The Fetch entry has a neutral bundle with `node:async_hooks` as its only Node import; its command, query, and SSE paths run in a Next.js App Router route handler on the Node.js runtime, with Bun and Deno smoke checks; Cloudflare Workers and the Next.js Edge runtime are not supported. See [Fetch API runtimes](Documentation/hosts/fetch-runtimes.md). The root workspace needs Node.js 22.19 or later, because it installs the Chronicle SDK; Node.js 24 LTS is recommended.
Every package manifest is at version 0.51.0. That is the version of this source preview, not an npm release, and the Chronicle package is experimental. The packages ship ES modules only, and schemas use Zod 4. The default core entry, host adapters, MongoDB, and Drizzle packages need Node.js 22 or later. The Fetch entry has a neutral bundle with `node:async_hooks` as its only Node import; its command, query, and SSE paths run in a Next.js App Router route handler on the Node.js runtime, with Bun and Deno smoke checks; Cloudflare Workers and the Next.js Edge runtime are not supported. See [Fetch API runtimes](Documentation/hosts/fetch-runtimes.md). The root workspace needs Node.js 22.19 or later, because it installs the Chronicle SDK; Node.js 24 LTS is recommended.

## Try it

Expand Down
6 changes: 3 additions & 3 deletions Source/Chronicle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/arc.chronicle",
"version": "0.50.0",
"version": "0.51.0",
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -34,8 +34,8 @@
"README.md"
],
"peerDependencies": {
"@cratis/arc.core": "^0.50.0",
"@cratis/arc.testing": "^0.50.0",
"@cratis/arc.core": "^0.51.0",
"@cratis/arc.testing": "^0.51.0",
"@cratis/chronicle": "^6.17.0",
"@cratis/fundamentals": "^7.19.6",
"rxjs": "^7.8.2",
Expand Down
2 changes: 1 addition & 1 deletion Source/CodeAnalysis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/eslint-plugin-arc-core",
"version": "0.50.0",
"version": "0.51.0",
"type": "module",
"license": "MIT",
"description": "ESLint diagnostics for Arc for TypeScript server artifacts",
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/arc.core",
"version": "0.50.0",
"version": "0.51.0",
"type": "module",
"license": "MIT",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion Source/Cratis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/cratis",
"version": "0.50.0",
"version": "0.51.0",
"type": "module",
"license": "MIT",
"description": "Arc and experimental Chronicle composition for Node.js",
Expand Down
4 changes: 2 additions & 2 deletions Source/Drizzle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/arc.drizzle",
"version": "0.50.0",
"version": "0.51.0",
"type": "module",
"license": "MIT",
"publishConfig": {
Expand Down Expand Up @@ -29,7 +29,7 @@
"README.md"
],
"peerDependencies": {
"@cratis/arc.core": "^0.50.0",
"@cratis/arc.core": "^0.51.0",
"@cratis/fundamentals": "^7.19.6",
"drizzle-orm": "^0.45.0",
"rxjs": "^7.8.2"
Expand Down
2 changes: 1 addition & 1 deletion Source/Express/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/arc.express",
"version": "0.50.0",
"version": "0.51.0",
"type": "module",
"license": "MIT",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion Source/Fastify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/arc.fastify",
"version": "0.50.0",
"version": "0.51.0",
"type": "module",
"license": "MIT",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion Source/Hono/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/arc.hono",
"version": "0.50.0",
"version": "0.51.0",
"type": "module",
"license": "MIT",
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions Source/MongoDB/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/arc.mongodb",
"version": "0.50.0",
"version": "0.51.0",
"type": "module",
"license": "MIT",
"publishConfig": {
Expand Down Expand Up @@ -29,7 +29,7 @@
"README.md"
],
"peerDependencies": {
"@cratis/arc.core": "^0.50.0",
"@cratis/arc.core": "^0.51.0",
"@cratis/fundamentals": "^7.19.6",
"@opentelemetry/api": "^1.9.0",
"mongodb": "^6.21.0",
Expand Down
2 changes: 1 addition & 1 deletion Source/Testing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/arc.testing",
"version": "0.50.0",
"version": "0.51.0",
"type": "module",
"license": "MIT",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion Source/Tools/ProxyGenerator/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { watchSource } from './watchSource.js';
const usage = 'Usage: arc-proxygenerator --project <tsconfig> --artifacts <folder> --output <folder>' +
' [--metadata <file> | --use-generated-metadata] [--check-metadata | --watch]' +
' [--root-namespace <namespace>] [--api-prefix=<prefix>] [--segments-to-skip <number>]' +
' [--use-proxy-file-suffix] [--skip-index-generation] [--skip-output-deletion] [--emit-interfaces]';
' [--use-proxy-file-suffix] [--skip-index-generation] [--skip-output-deletion] [--emit-interfaces] [--skip-react-hooks]';

async function generateManifest(): Promise<void> {
const [manifestPath, outputRoot, extra] = process.argv.slice(2);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Cratis. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
import { renderSource } from '../../renderSource.js';
import { a_captured_contract } from '../given/a_captured_contract.js';

describe('when rendering with react hooks by default', () => {
let files: ReadonlyMap<string, string>;
beforeEach(() => { files = renderSource(new a_captured_contract().analysis); });
it('should import the react command hook', () => {
files.get('differential/fixture/commands/CreateFixtures.ts')!.should.include("from '@cratis/arc.react/commands';");
files.get('differential/fixture/commands/CreateFixtures.ts')!.should.include('static use(initialValues?: ICreateFixtures)');
});
it('should import the react query hooks', () => {
files.get('differential/fixture/models/All.ts')!.should.include("from '@cratis/arc.react/queries';");
files.get('differential/fixture/models/All.ts')!.should.include('static use(');
files.get('differential/fixture/models/All.ts')!.should.include('static when(');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Cratis. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
import { renderSource } from '../../renderSource.js';
import { a_captured_contract } from '../given/a_captured_contract.js';

describe('when skipping react hooks for commands and queries', () => {
let files: ReadonlyMap<string, string>;
beforeEach(() => { files = renderSource(new a_captured_contract().analysis, { skipReactHooks: true }); });
it('should not import react from any generated file', () => {
for (const text of files.values()) text.should.not.include('@cratis/arc.react');
});
it('should not emit use hooks on the command', () => {
files.get('differential/fixture/commands/CreateFixtures.ts')!.should.not.match(/static use/);
});
it('should not emit hooks or when on the queries', () => {
for (const name of ['All', 'Observe', 'Search'])
files.get(`differential/fixture/models/${name}.ts`)!.should.not.match(/static (use|when)/);
});
it('should keep the typed client classes', () => {
files.get('differential/fixture/commands/CreateFixtures.ts')!.should.include("import { Command } from '@cratis/arc/commands';");
files.get('differential/fixture/commands/CreateFixtures.ts')!.should.include('export class CreateFixtures extends Command<');
files.get('differential/fixture/models/Observe.ts')!.should.include('export class Observe extends ObservableQueryFor<');
});
it('should keep the sorting helpers for array queries', () => {
files.get('differential/fixture/models/All.ts')!.should.include('static get sortBy()');
});
});
2 changes: 1 addition & 1 deletion Source/Tools/ProxyGenerator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cratis/arc.proxygenerator",
"version": "0.50.0",
"version": "0.51.0",
"description": "TypeScript source analyzer and deterministic Arc client proxy generator",
"repository": {
"type": "git",
Expand Down
5 changes: 3 additions & 2 deletions Source/Tools/ProxyGenerator/parseSourceOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function parseSourceOptions(values: readonly string[], usage: string):
const options: Record<string, string | boolean> = {};
const flags = ['--skip-command-name-in-route', '--skip-query-name-in-route', '--use-proxy-file-suffix', '--js-import-specifiers',
'--skip-index-generation', '--skip-output-deletion', '--emit-interfaces', '--watch', '--check-metadata',
'--use-generated-metadata'];
'--use-generated-metadata', '--skip-react-hooks'];
const arguments_ = ['--project', '--artifacts', '--output', '--metadata', '--segments-to-skip', '--api-prefix', '--root-namespace'];
for (let index = 0; index < values.length; index++) {
const [key, attached] = values[index]!.split(/=(.*)/s, 2);
Expand Down Expand Up @@ -37,7 +37,8 @@ export function parseSourceOptions(values: readonly string[], usage: string):
rootNamespace: typeof options['--root-namespace'] === 'string' ? options['--root-namespace'] : undefined,
skipIndexGeneration: options['--skip-index-generation'] === true,
skipOutputDeletion: options['--skip-output-deletion'] === true,
emitInterfaces: options['--emit-interfaces'] === true
emitInterfaces: options['--emit-interfaces'] === true,
skipReactHooks: options['--skip-react-hooks'] === true
};
return { configuration, watch: options['--watch'] === true, checkMetadata: options['--check-metadata'] === true };
}
2 changes: 2 additions & 0 deletions Source/Tools/ProxyGenerator/renderSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface SourceRenderOptions {
readonly recordedRules?: ReadonlyMap<string, readonly RecordedRule[]>;
readonly onDiagnostic?: (message: string) => void;
readonly emitInterfaces?: boolean;
/** Omit the `@cratis/arc.react` import and the static `use*` hooks from generated commands and queries. */
readonly skipReactHooks?: boolean;
}
const notice = `/*---------------------------------------------------------------------------------------------
* **DO NOT EDIT** - This file is an automatically generated file.
Expand Down
Loading
Loading