Skip to content

Commit aae7119

Browse files
committed
feat(website): optimized API and new simpler website design/documentation
1 parent 7c8151b commit aae7119

File tree

227 files changed

+11635
-3889
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

227 files changed

+11635
-3889
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ jobs:
2222
SFTP_USERS: user:123:::upload
2323
ports:
2424
- '2222:22'
25+
redis:
26+
image: redis:7.0.11
27+
ports:
28+
- '6379:6379'
29+
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
2530
steps:
2631
- uses: actions/checkout@v4
2732

@@ -35,10 +40,12 @@ jobs:
3540
packages/api-console-module/tsconfig.json \
3641
packages/angular-ssr/tsconfig.json \
3742
packages/broker/tsconfig.json \
43+
packages/broker-redis/tsconfig.json \
3844
packages/bson/tsconfig.json \
3945
packages/core/tsconfig.json \
4046
packages/core-rxjs/tsconfig.json \
4147
packages/filesystem/tsconfig.json \
48+
packages/filesystem-database/tsconfig.json \
4249
packages/framework/tsconfig.json \
4350
packages/framework-debug-api/tsconfig.json \
4451
packages/framework-integration/tsconfig.json \
@@ -60,10 +67,12 @@ jobs:
6067
run: |
6168
npm run test:coverage \
6269
packages/broker/ \
70+
packages/broker-redis/ \
6371
packages/bson/ \
6472
packages/core/ \
6573
packages/core-rxjs/ \
6674
packages/filesystem/ \
75+
packages/filesystem-database/ \
6776
packages/framework/ \
6877
packages/framework-debug-api/ \
6978
packages/framework-integration/ \

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"clean": "find packages/*/dist/* ! -name 'package.json' -type f -exec rm -f {} +; rm -rf packages/*/.angular; rm -rf website/.angular; npm run postinstall",
1818
"clean:modules": "rm -rf packages/*/node_modules; rm -rf node_modules",
1919
"clean:lock": "rm -rf packages/*/package-lock.json; rm -rf package-lock.json",
20-
"docs": "rm -rf docs && node --max-old-space-size=12096 node_modules/.bin/typedoc packages/*/index.ts",
20+
"docs": "rm -rf docs && node --max-old-space-size=12096 node_modules/.bin/typedoc --options typedoc.js packages/*/index.ts",
2121
"publish": "lerna publish --no-private patch",
2222
"publish-force": "npm run build && lerna publish --no-private --force-publish",
2323
"check:circular": "madge --extensions ts --warning --circular",

packages/api-console-gui/src/app/components/inputs/date-input.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { TypeDecoration } from '../../utils.js';
88
@Component({
99
template: `
1010
<dui-input round lightFocus type="datetime-local" style="width: 100%"
11-
(keyDown)="keyDown.emit($event)"
11+
(keydown)="keyDown.emit($event)"
1212
[(ngModel)]="model().value" />
1313
`,
1414
imports: [

packages/api-console-gui/src/app/components/inputs/string-input.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { FormsModule } from '@angular/forms';
88
@Component({
99
template: `
1010
<dui-input lightFocus [type]="getType()" style="width: 100%"
11-
(keyDown)="keyDown.emit($event)"
11+
(keydown)="keyDown.emit($event)"
1212
[placeholder]="placeholder()"
1313
[(ngModel)]="model().value"
1414
></dui-input>

packages/app/src/app.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,14 @@ import { ConfigLoader, ServiceContainer } from './service-container.js';
1313
import { ConfigureProviderOptions, injectedFunction, InjectorContext, ResolveToken, Scope, Token } from '@deepkit/injector';
1414
import { AppModule, RootModuleDefinition } from './module.js';
1515
import { EnvConfiguration } from './configuration.js';
16-
import {
17-
DataEventToken,
18-
DispatchArguments,
19-
EventDispatcher,
20-
EventDispatcherDispatchType,
21-
EventListener,
22-
EventListenerCallback,
23-
EventToken,
24-
} from '@deepkit/event';
16+
import { DataEventToken, DispatchArguments, EventDispatcher, EventDispatcherDispatchType, EventListener, EventListenerCallback, EventToken } from '@deepkit/event';
2517
import { ReceiveType, ReflectionClass, ReflectionKind } from '@deepkit/type';
2618
import { Logger } from '@deepkit/logger';
2719
import { executeCommand, getArgsFromEnvironment, getBinFromEnvironment } from './command.js';
2820

21+
/**
22+
* @internal
23+
*/
2924
export function setPartialConfig(target: { [name: string]: any }, partial: {
3025
[name: string]: any
3126
}, incomingPath: string = '') {
@@ -160,10 +155,13 @@ class EnvConfigLoader {
160155
}
161156
}
162157

158+
/**
159+
* @internal
160+
*/
163161
export class RootAppModule<T extends RootModuleDefinition> extends AppModule<T> {
164162
}
165163

166-
export interface AppEvent {
164+
interface AppEvent {
167165
/**
168166
* The command that is about to be executed.
169167
*/
@@ -177,12 +175,12 @@ export interface AppEvent {
177175
injector: InjectorContext;
178176
}
179177

180-
export interface AppExecutedEvent extends AppEvent {
178+
interface AppExecutedEvent extends AppEvent {
181179
exitCode: number;
182180
}
183181

184182

185-
export interface AppErrorEvent extends AppEvent {
183+
interface AppErrorEvent extends AppEvent {
186184
error: Error;
187185
}
188186

@@ -211,13 +209,10 @@ export const onAppError = new DataEventToken<AppErrorEvent>('app.error');
211209
export const onAppShutdown = new DataEventToken<AppEvent>('app.shutdown');
212210

213211
/**
214-
* This is the smallest available application abstraction in Deepkit.
215-
*
216-
* It is based on a module and executes registered CLI controllers in `execute`.
217-
*
218-
* @deepkit/framework extends that with a more powerful Application class, that contains also HTTP and RPC controllers.
212+
* This is the application abstraction in Deepkit.
219213
*
220-
* You can use this class for more integrated unit-tests.
214+
* It is based on a module (the root module)
215+
* and executes registered CLI controllers in `execute`.
221216
*/
222217
export class App<T extends RootModuleDefinition> {
223218
protected envConfigLoader?: EnvConfigLoader;

packages/app/src/command.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ export interface Command {
7171
execute(...args: any[]): Promise<number | void> | number | void;
7272
}
7373

74-
export function isCommand(classType: ClassType<Command>) {
75-
return !!cli._fetch(classType);
76-
}
77-
78-
7974
function convert(parameter: CommandParameter, value: any) {
8075
if (value === undefined) {
8176
if (parameter.optional) return undefined;
@@ -215,6 +210,9 @@ function getSpacing(names: string[]): number {
215210
return names.reduce((max, name) => Math.max(max, name.length), 0) + 1;
216211
}
217212

213+
/**
214+
* @internal
215+
*/
218216
export interface ParsedCliControllerConfig {
219217
controller?: ClassType,
220218
callback?: Function;
@@ -241,7 +239,7 @@ function commandNameFromSymbol(symbolName: string) {
241239
.replace(/-command$/, '').replace(/-controller/, '-');
242240
}
243241

244-
export function parseControllerConfig(config: ControllerConfig): ParsedCliControllerConfig {
242+
function parseControllerConfig(config: ControllerConfig): ParsedCliControllerConfig {
245243
let name = config.name || '';
246244
let description = '';
247245
if (!name && config.controller) {
@@ -352,7 +350,7 @@ function printHelp(script: string, command: ParsedCliControllerConfig, writer: C
352350
}
353351
}
354352

355-
export type CommandWriter = (...message: any[]) => void;
353+
type CommandWriter = (...message: any[]) => void;
356354

357355
interface ParameterMeta {
358356
flag: boolean;
@@ -604,7 +602,7 @@ function getActualCliParameterName(parameter: { prefix: string, name: string })
604602
return parameter.prefix ? parameter.prefix + '.' + parameter.name : parameter.name;
605603
}
606604

607-
export async function runCommand(
605+
async function runCommand(
608606
config: ParsedCliControllerConfig,
609607
argv: string[],
610608
injector: InjectorContext,

packages/app/src/configuration.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { existsSync, readFileSync } from 'fs';
1414
class ConfigOptionNotFound extends Error {
1515
}
1616

17-
export function resolveEnvFilePath(path: string): string | undefined {
17+
function resolveEnvFilePath(path: string): string | undefined {
1818
const resolvedPath = isAbsolute(path) ? path : findFileUntilPackageRoot(path);
1919
if (!resolvedPath || !existsSync(resolvedPath)) return undefined;
2020

@@ -38,6 +38,9 @@ function findFileUntilPackageRoot(fileName: string): string | undefined {
3838
}
3939
}
4040

41+
/**
42+
* @internal
43+
*/
4144
export class EnvConfiguration {
4245
protected container: { [name: string]: any } = {};
4346

packages/app/src/module.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,12 @@ import { InjectorModule, InjectorModuleConfig, NormalizedProvider, ProviderWithS
1212
import { AbstractClassType, ClassType, CustomError, ExtractClassType, isClass } from '@deepkit/core';
1313
import { EventListener, EventToken } from '@deepkit/event';
1414
import { WorkflowDefinition } from '@deepkit/workflow';
15-
import {
16-
getPartialSerializeFunction,
17-
ReflectionFunction,
18-
ReflectionKind,
19-
ReflectionMethod,
20-
resolveReceiveType,
21-
serializer,
22-
Type,
23-
TypeClass,
24-
} from '@deepkit/type';
15+
import { getPartialSerializeFunction, ReflectionFunction, ReflectionKind, ReflectionMethod, resolveReceiveType, serializer, Type, TypeClass } from '@deepkit/type';
2516
import { ControllerConfig } from './service-container.js';
2617

18+
/**
19+
* @internal
20+
*/
2721
export interface MiddlewareConfig {
2822
getClassTypes(): ClassType[];
2923
}
@@ -44,6 +38,9 @@ export interface AddedListener {
4438
order: number;
4539
}
4640

41+
/**
42+
* Stringifies the listener to a human-readable string.
43+
*/
4744
export function stringifyListener(listener: AddedListener): string {
4845
if (listener.classType) {
4946
return listener.classType.name + '.' + listener.methodName;
@@ -182,7 +179,6 @@ export interface CreateModuleDefinition extends ModuleDefinition {
182179
}
183180

184181
export type FunctionalModule = (module: AppModule<any>) => void;
185-
export type FunctionalModuleFactory = (...args: any[]) => (module: AppModule<any>) => void;
186182

187183
export interface RootModuleDefinition extends ModuleDefinition {
188184
/**
@@ -198,13 +194,17 @@ let moduleId = 0;
198194

199195
/**
200196
* @reflection never
197+
* @internal
201198
*/
202199
export type DeepPartial<T> =
203200
T extends string | number | bigint | boolean | null | undefined | symbol | Date | Set<any> | Map<any, any> | Uint8Array | ArrayBuffer | ArrayBufferView | Error | RegExp | Function | Promise<any> ? T :
204201
Partial<{
205202
[P in keyof T]: DeepPartial<T[P]>;
206203
}>;
207204

205+
/**
206+
* @internal
207+
*/
208208
export interface AppModuleClass<C extends InjectorModuleConfig> {
209209
new(config?: DeepPartial<C>): AppModule<C>;
210210
}

packages/app/tests/application.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { beforeEach, expect, test } from '@jest/globals';
2-
import { App, AppErrorEvent, AppEvent, AppExecutedEvent, onAppError, onAppExecute, onAppExecuted, onAppShutdown } from '../src/app.js';
2+
import { App, onAppError, onAppExecute, onAppExecuted, onAppShutdown } from '../src/app.js';
33
import { ClassType, Inject, isClass } from '@deepkit/core';
44
import { ProviderWithScope, Token } from '@deepkit/injector';
55
import { AppModule, createModule, createModuleClass } from '../src/module.js';
6-
import { BaseEvent, DataEvent, DataEventToken, EventDispatcher, eventDispatcher, EventToken } from '@deepkit/event';
6+
import { BaseEvent, DataEvent, DataEventToken, EventDispatcher, eventDispatcher, EventOfEventToken, EventToken } from '@deepkit/event';
77
import { cli, Command, Flag } from '../src/command.js';
88
import { ControllerConfig, ServiceContainer } from '../src/service-container.js';
99

@@ -595,10 +595,10 @@ test('events', async () => {
595595
class MyService {
596596
}
597597

598-
let executeEvent: AppEvent | undefined = undefined;
599-
let executedEvent: AppExecutedEvent | undefined = undefined;
600-
let errorEvent: AppErrorEvent | undefined = undefined;
601-
let shutdownEvent: AppEvent | undefined = undefined;
598+
let executeEvent: EventOfEventToken<typeof onAppExecute> | undefined = undefined;
599+
let executedEvent: EventOfEventToken<typeof onAppExecuted> | undefined = undefined;
600+
let errorEvent: EventOfEventToken<typeof onAppError> | undefined = undefined;
601+
let shutdownEvent: EventOfEventToken<typeof onAppShutdown> | undefined = undefined;
602602

603603
const app = new App({
604604
providers: [MyService],

packages/bench/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const AsyncFunction = (async () => {
1+
const AsyncFunction = (async () => {
22
}).constructor as { new(...args: string[]): Function };
33

44
function noop() {
@@ -76,6 +76,10 @@ function report(benchmark: Benchmark) {
7676
);
7777
}
7878

79+
/**
80+
* Registers a benchmark with the given name and function.
81+
* Function can be synchronous or asynchronous.
82+
*/
7983
export function benchmark(name: string, fn: () => void) {
8084
benchmarks.push({
8185
name, fn,
@@ -89,6 +93,9 @@ export function benchmark(name: string, fn: () => void) {
8993
});
9094
}
9195

96+
/**
97+
* Runs all registered benchmarks each for the given number of seconds.
98+
*/
9299
export async function run(seconds: number = 1) {
93100
print('Node', process.version);
94101

@@ -130,13 +137,6 @@ const asyncExecutors = [
130137
getAsyncExecutor(1000000),
131138
];
132139

133-
const gcObserver = new PerformanceObserver((list) => {
134-
for (const entry of list.getEntries()) {
135-
current.gcEvents.push(entry.duration);
136-
}
137-
});
138-
const a = gcObserver.observe({ entryTypes: ['gc'] });
139-
140140
function test(seconds: number) {
141141
let iterations = 1;
142142
let samples: number[] = [];

0 commit comments

Comments
 (0)