A new full-featured and high-performance TypeScript framework
MIT License
Bot releases are hidden (Show)
This release contains a lot of bugfixes and features. We're working towards the first beta release. You can read more about what is included in the beta in its milestone: https://github.com/deepkit/deepkit-framework/milestone/1
class MyController {
@rpc.action()
async startMigration(): Promise<ProgressTracker> {
const progressTracker = new ProgressTracker();
const total = 100;
const track = progressTracker.track('migration', total); //multiple tracks are possible
setTimeout(async () => {
for (let i = 0; i < total; i++) {
if (!track.running) break; //user aborted
//to some heavy work
//both will be streamed to the client
track.message = `migration: ${table}`;
track.done++;
}
});
return progressTracker;
}
}
const controller = rpcClient.controller<MyController>('/controller');
const progress = await controller.startMigration();
progress.subscribe(() => {
console.log(`progress: ${progress.done}/${progress.total}: ${progress.message}`);
});
abortButton.onclick = () => progress.stop();
In @deepkit/desktop-ui there is now a new component that shows progress
:
<dui-progress-indicator display="vertical" [progressTracker]="progress"></dui-progress-indicator>
https://user-images.githubusercontent.com/450980/235517163-67866f4a-b290-43f3-aa3a-8375fb803a20.mov
Core: Add range and zip functions (3dcb39cd)
Same as in Python
Core-RxJS: Add decoupleSubject + more docs (850b99af)
In order to send RXJS shared Subject/BehaviourSubject/ProgressTracker to the client, you can now use decoupleSubject,
so that the origin subject will not be completed when the client disconnects or manually completes.
//a service not part of 'rpc' scope, so its shared between all clients
class AppState {
progresses: { [id: number]: ProgressTracker } = {};
}
class MyController {
constructor(private state: AppState) {
}
@rpc.action()
getProgress(id: number): ProgressTracker {
//multiple clients can access the progress
return decoupleSubject(this.state.progresses[id]);
}
@rpc.action()
startProgress(id: number): ProgressTracker {
this.state.progresses[id] = new ProgressTracker();
}
}
RPC: Make RpcKernelSecurity scoped (d2740e86)
This allows to inject rpc
scoped providers into the security class.
Type: Add to validation errors the value that caused the error (98fa1ab2)
This allows to show the value that caused the error in the validation error message.
const oldError = { code: 'minLength', message: 'Min length is 3', path: 'username' }
const newError = { code: 'minLength', message: 'Min length is 3', path: 'username', value: 'Pe' }
Type: TypedFormGroup supports now new Angular version (7966ac52)
With this change you can use TypedFormGroup with Angular 14+.
Type: Implement call signatures in object literals (ece8c021)
With this change it's now supported to read call signatures from TypeScript types.
interface Caller {
(a: number): string;
}
const type = typeOf<Caller>();
assertType(type, ReflectionKind.objectLiteral);
for (const member of resolveTypeMembers(type)) {
//one member will be of kind ReflectionKind.callSignature
}
Type: Allow working with null objects (2e3f454a)
This change allows to work with null objects (objects created via Object.create(null)
).
Type-Compiler: Use TS config resolution code to resolve reflection options (bb2ac7e4)
This is an important change in the way the Type-Compiler resolves tsconfig options.
The old way was our own tsconfig.json resolution algorithm, but with this change we read
CompilerOptions.configFilePath
which is much more correct.
Type-Compiler: Support esm module (48de497f)
This should enable the use of @deepkit/type-compiler in ESM environments.
Type-Compiler: Print correct module specifier when module was not found (06e38760)
Type-Compiler: Load compilerOptions.paths
manually if not provided (d872afcd)
Injector: Allow using sub configuration classes as dependency (ba7c68e1)
Application configurations can now be split into multiple classes and still be used as dependency.
class DatabaseConfig {
host: string = 'localhost';
port: number = 3306;
}
class AppConfiguration {
database: DatabaseConfig = new DatabaseConfig;
}
class Database {
//refering to a child of `AppConfiguration` is new!
constructor(config: DatabaseConfig) {
}
}
const app = new App({
config: AppConfiguration,
providers: [
Database
]
}).run();
Mongo: Adds support for expireAfterSeconds index (81765c53)
Mongo: Adds export for FindAndModifyCommand to allow $rename (6a00da9f)
Mongo: Adds export for AggregateCommand to allow custom queries (7f6b4b33)
Mongo: Adds export for UpdateCommand to allow custom queries (4d627d2e)
API-Console-GUI: Show the route description with white-space:pre-wrap to respect the newlines the developer used in description for formatting (058f0904)
HTTP: Graceful shutdown including waiting for active http requests (09fb4d5b)
HTTP: Add thrown Error
in controller to http.OnAccessDenied event (53ffb33d)
HTTP: Add support for DI auto-wiring in methods of event class listeners (ff432d80)
HTTP: Allow injecting http values (query/path/header) into http listener (01c24c4a)
This allows to inject services and HTTP request data into http listeners the same way as it is possible in routes.
@http.controller('/:groupId')
class Controller {
@http.GET('/:userId')
handle(userId: number, request: HttpRequest) {
// ...
}
}
class Listener {
@eventDispatcher.listen(httpWorkflow.onController)
handle(event: typeof httpWorkflow.onController.event, groupId: HttpPath<number>) {
// access to the route path parameter `:groupId`
}
}
HTTP: Handle HttpError errors in parameter resolver (0ead2fe2)
Additionally, to HttpQuery, HttpBody, HttpQueries it's now possible to inject header values.
class Controller {
@http.GET('/:userId')
handle(userId: number, authorization: HttpHeader<string>) {
// access HTTP 'authorization' header
}
}
HTTP: Allow reading parameter object (name -> value) for a route in onController event (6872dee0)
Desktop-UI: Add new state abstraction (e786f090)
This introduces a new state abstraction model for complex applications. It allows to register
a class with properties and methods as state. The state is monitored and change-detection (as well as state persistence)
triggered automatically. Properties marked as PartOfUrl
will be persisted automatically in the URL (query parameter).
class State extends EfficientState {
// stored in URL
shop: number & PartOfUrl = 0;
// stored in localStorage
sidebarVisible: boolean = true;
}
@NgModule({
providers: [
provideState(State)
],
})
export class AppModule {
}
@Component({
template: `
Store: {{state.shop}}
<!-- This triggers state listeners and changes the URL since PartOfUrl -- >
<dui-button(click) = 'state.shop = 2' > Change < /dui-button>
`
})
class Component {
constructor(public state: State) {
}
}
Desktop-UI: Table freezed columns support (e786f090)
This allows to freeze columns in a table. The user can then scroll the table horizontally and the frozen columns
will stay visible.
<dui-table [items]="items" [freezeColumns]="1">
// ...
</dui-table>
https://user-images.githubusercontent.com/450980/235516878-0773d357-cfd8-4ee5-81c1-e5958cf115b0.mov
This feature allows to attach hotkeys to arbitrary dui-buttons.
<dui-button hotkey="meta+s">Save</dui-button>
The user can now press cmd+s
to trigger the button. When alt (or option on macOS) is pressed,
the button will reveal its keymap.
https://user-images.githubusercontent.com/450980/235516952-116d2218-307f-48e9-b3f8-e19dbd49e98a.mov
ORM: Support RegExp directly as filter value + case-insensitive filter (b14fca22)
ORM: Support Query.use in joins (2ac48663)
ORM: Add Query.use/Query.fetch method to allow more dynamic query composition (ee439cd9)
Add everywhere .js extension to support ESM (2fd3dda9)
This should be it possible to use Deepkit Framework in ESM environments.
keyof this
as any
so that it does not work in a strange unexpected way (e02fa0d2)globalThis
to access the global object (7af681bd)Full Changelog: https://github.com/deepkit/deepkit-framework/compare/v1.0.1-alpha.87...v1.0.1-alpha.93
Published by marcj over 1 year ago
npm init @deepkit/app my-app
(81fc37a6)type
from ValidationError as it's not easily serializable in BSON (d773a7c2)ALTER TABLE
into one in schema migration (243bee97)npx update-by-scope @deepkit
Published by marcj almost 2 years ago
npm init @deepkit/app project-name
(3088e829)To update your project to the newest Deepkit versions, you can use:
npx update-by-scope @deepkit
c3242b94 - feature(http): allow to resolve parameter resolver from parent modules [Marc J. Schmidt]
86600993 - feature(type): support for generic class type reflection [Marc J. Schmidt]
1d984fec - feature(type): keep typeName + typeArguments of the expression chain and set type.typename to first (not last anymore). [Marc J. Schmidt]
0e5543aa - fix(type-compiler): do not transform {default() {}} expression as function name can not be preserved. [Marc J. Schmidt]
c94175b3 - fix(type): type any correctly validates. [Marc J. Schmidt]
0e62b1d7 - fix(type): added isSameType(function, function) strict comparison on function implementations (#330) [Tim van Dam]
41264ee2 - fix: lock time drift [Marc J. Schmidt]
dbf71b05 - fix(orm): join without hydration. [Marc J. Schmidt]
88ce7d46 - fix(type): keep type annotations when intersection already decorated type. [Marc J. Schmidt]
9cc2e278 - chore(type): test to cover function parameter serialisation [Marc J. Schmidt]
c0f5299f - chore(sqlite): make sure m2m joins work [Marc J. Schmidt]
Published by marcj over 2 years ago
c2400a65 - feature(type): support static reflection [Marc J. Schmidt]
27f7ec2d - fix(framework): app:config now creates a table that does not overflow (#309) [Tim van Dam]
76aa7166 - fix(http): fix route resolving for routes taking no params (#306) [Char2s]
da9e415c - fix(http): do not use JSONResponse/HTMLResponse runtime types for serialisation [Marc J. Schmidt]
291c96c0 - fix(type): same-type check for enum, fixes multiple enums in unions. [Marc J. Schmidt]
aa19caba - fix(type): support readonly T
expression. [Marc J. Schmidt]
a8265b05 - fix(type): isFunction for minimised class expressions [Marc J. Schmidt]
20cb35fa - fix(type): correct use of readonly keyword on constructor properties [Marc J. Schmidt]
293a335a - fix(type-compiler): decorating export default async functions correctly [Marc J. Schmidt]
aefc2ac7 - fix(http): disable stream test [Marc J. Schmidt]
fe633da5 - fix(sql): delete query correctly serialises constraint [Marc J. Schmidt]
e56a5af5 - fix(framework): setup logger correctly in createTestingApp [Marc J. Schmidt]
5d33aa03 - chore: add dark mode/white deepkit logo to README (#310) [Tim van Dam]
81d998c5 - chore(type): add test for camel case naming strategy. [Marc J. Schmidt]
8b347fc7 - chore(type): add test for exported type string literals [Marc J. Schmidt]
Published by marcj over 2 years ago
Version alpha-72 comes with a lot of new features and bugfixes.
New much more extensive documentation at https://docs.deepkit.io in 3 languages. Please note this is still in progress. We are constantly improving the documentation.
HTTP functional API. See Documentation Functional API
const app = new App({
providers: [Database],
imports: [new FrameworkModule]
});
const router = app.get(HttpRouterRegistry);
router.get('/:text', (text: string) => {
return 'Hello ' + text;
});
router.get('/user/:id', async (id: number & Positive, database: Database) => {
return await database.query(User).filter({id}).findOne();
});
new App({
listeners: [
onServerMainBootstrap.listen((event, logger: Logger) => {
logger.log('Server started');
});
],
}).run();
3016a288 - feature(sql): infer new Date
default value as NOW() column DEFAULT expression. [Marc J. Schmidt]
9ba00d08 - feature(http): update formidable to v2 [Marc J. Schmidt]
8c675ecd - feat(injector): support type injection on Injector
[Char2s]
b6436ed1 - feature(app): functional modules [Marc J. Schmidt]
8639d896 - feat(http): implement stream support [Char2s]
ba98832b - feature(http): allow to provide RegExp object in R
in HttpRegExp[T, R]. [Marc J. Schmidt]
beb9ef13 - feature(type): add test for dynamic runtime types [Marc J. Schmidt]
2dc1fbf7 - feature(framework): allow to listen to orm events in modules [Marc J. Schmidt]
0812f684 - feature(orm): use @deepkit/event for event handling [Marc J. Schmidt]
4aae2fed - feature(event): allow to register late listeners [Marc J. Schmidt]
41e5564f - feature(type): allow to control whether properties set explicitly undefined for null/undefined values. [Marc J. Schmidt]
03dde6e3 - feat(framework): replace TestHttpResponse
with MemoryHttpResponse
(#245) [Char2s]
30939492 - feature(type-compiler): stop using TypeChecker entirely and allow loader-pattern, to better support webpack/esbuild/SWC. [Marc J. Schmidt]
20f94f6d - feat(http): add more http errors [Char2s]
7fe644a0 - feature(injector): Allow to use Inject[] in factories [Marc J. Schmidt]
a599b7ca - feat(orm): redesign query filter methods (#257) [Char2s]
63991525 - fix(type-compiler): default default function [Marc J. Schmidt]
ddee3f9d - fix(type): TypeClass contains now all properties [Marc J. Schmidt]
77500537 - chore: ignore tests in npm publish [Marc J. Schmidt]
be4571de - chore: fix install compiler in GUI projects [Marc J. Schmidt]
26add9aa - chore: fix package stuff [Marc J. Schmidt]
07c991f1 - fix(http): adjust parse body for new formidable API [Marc J. Schmidt]
aa5cd0af - fix(type): keep annotations when same type is intersected [Marc J. Schmidt]
7a3eb8e4 - chore: update various packages and update package-lock to v2 [Marc J. Schmidt]
a7b35bfa - chore(orm): coding style [Marc J. Schmidt]
3752d4ec - chore(crypto): initialise createBuffer once [Marc J. Schmidt]
3ad5f5b8 - fix(crypto): use Uint8Array in browsers [Keritial]
7e384143 - docs(dev): add package prerequisites [Char2s]
cc1ad3d6 - chore(type): assert union test [Marc J. Schmidt]
0703a795 - fix(http): fix parameter resolver context value [Char2s]
1385d264 - Input arg for PUT method in autocrud updated to type HttpBody [Kiran K]
86f61b14 - fix(postgres): add @types/pg to dependencies [Tim van Dam]
1cce6e60 - fix(injector): remove unused deps
property [Tim van Dam]
c336067e - fix(http): filterMiddlewaresForRoute should only needs one match [Nex Zhu]
4374fa7d - Fix an error reported by TSC 4.7.4 [Rafael Ávila de Espíndola]
92804128 - Use host.resolveModuleNames when available [Rafael Ávila de Espíndola]
78b8559f - fix(type): empty array validation keep state intact [Marc J. Schmidt]
db2ee9af - fix(api-console): use correct environment headers in requests [Marc J. Schmidt]
263b107c - chore: fix typedoc [Marc J. Schmidt]
13ef6877 - fix(type): infer parameters of function with a single parameter [Marc J. Schmidt]
ae1f6d00 - chore(http): add test for reference deserialization [Marc J. Schmidt]
3c0f711b - chore: enable pull requests builds [Marc J. Schmidt]
17160ac6 - chore: try buildjet 2vcpu [Marc J. Schmidt]
fe88e754 - chore: try buildjet [Marc J. Schmidt]
f7b59bb0 - chore: github actions mongo [Marc J. Schmidt]
292ce9dc - chore: bson readme [Marc J. Schmidt]
18b038f6 - chore: increase memory limit for test:coverage [Marc J. Schmidt]
0347bbdd - chore: remove typedoc [Marc J. Schmidt]
c082c754 - chore: try using github CI server [Marc J. Schmidt]
55a8a562 - fix(type): disabled loosely throws for primitives in cast() [Marc J. Schmidt]
aeaef017 - fix(api-console): fix request headers (#233) [Char2s]
568fa60a - chore(type): move test files to tests/ directly [Marc J. Schmidt]
25020bd7 - chore(injector): add test for inheritance [Marc J. Schmidt]
e135620d - fix(sql): limit with joins [Marc J. Schmidt]
a6f57345 - fix(api-console): serialize date correctly