Deepkit Framework Versions Save

A new full-featured and high-performance TypeScript framework

v1.0.1-alpha.93

1 year ago

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

Features

  • new ProgressTracker abstraction (2a36a127, c2e6be89, a8d3c955, 3483e20e) This new abstraction allows to monitor remote progress of a long-running task with a way to abort it.
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

  • Desktop-UI: Tab-button: remove [model] API (5b1e015b)
  • Desktop-IO: Hotkey component, animated duiDialog (like quick-look macOS) (327c35ce)

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.

Fixes

  • Logger: Maintain logger level when scoped logger is created (f590558a)
  • Type: Default assignment for optional literals (05247ae8)
  • Type: Treat keyof this as any so that it does not work in a strange unexpected way (e02fa0d2)
  • Logger: Don't use rawMessage in JSONTransport so that color xml is removed (e1f956c2)
  • RPC: Unwrap type only to determine inner type, don't use as return type (98982235)
  • Core: Move reflection option for database tests to it matches latest compiler changes (f9386432)
  • Core: Remove debug statement + set compiler host only when not overridden (713bd1cd)
  • Core: Removed debug statements (dc3abbce)
  • Core: Invalid json syntax in tsconfig (ac093c88)
  • Type-Compiler: Make sure only TS/TSX files are processed by the transformer (c4c508a6)
  • Type-Compiler: Duplicate method (48730fbd)
  • Injector: Missing factoryDependencyNotFound function in resolver compiler context (e0f3a1a3)
  • Type: Typo in error message (2a79e5a9)
  • SQL: Disconnect on test end (f8362478)
  • SQL: Array element serialization (f7d6c222)
  • SQL: Patch PK extraction when there were no modified rows (535ba298)
  • Bump Node to current LTS (18.x) (55035634)
  • ORM: Apply joins to preloaded entities from previous joins (aa90b17a)
  • HTTP: Enable streaming tests (c62906b1)
  • Angular-Universal: Adjust to new http parameter structure (e2accfb8)
  • Use cross-environment globalThis to access the global object (7af681bd)
  • Create-App: Remove .js extension for the files being created (11642051)
  • Template: Correct execution of functional components (8bd19c47)
  • Framework: Http worker wrong options + rpc for https (fabc1635)
  • ORM-Browser: Support detecting wss:// (c0d51f0b)

New Contributors

Full Changelog: https://github.com/deepkit/deepkit-framework/compare/v1.0.1-alpha.87...v1.0.1-alpha.93

v1.0.1-alpha.87

1 year ago

Features

  • ORM Browser Module: Allowed to serve ORM Browser in custom apps (d7ff30a4)
  • ORM: Added deep (dot path) patch support for all database adapters (0cec35f5)
  • HTTP: Silently serialize unpopulated references (9ac824d3)
  • Type: Detect primary-key-only reference objects (0f4cf65f)
  • Type: Support nested loosely typed discriminated unions (07c937bd)
  • Type: Added isGlobalTypeClass/isCustomTypeClass (ec55a42a)
  • Create App: publish @deepkit/create-app to easily setup a Deepkit project via npm init @deepkit/app my-app (81fc37a6)
  • Desktop UI: Support dynamic sidebars (3709d73d)
  • Desktop UI: Support angular v15 (7103470d)

Fixes

  • HTTP: Returned Response object are not serialized (221e9682)
  • Mongo: Fixed aggregation without accumulators (68770a6c)
  • Type: Correctly report invalid date types (10868e4f)
  • Unpopulated back references in class instances (9274e607)
  • Type: Remove type from ValidationError as it's not easily serializable in BSON (d773a7c2)
  • Mongo: Fixed early error in sockets correctly (a0268407)
  • SQL: Correctly merge multiple ALTER TABLE into one in schema migration (243bee97)
  • API Console Module: Dist needs to be present in unbuilt state so that linking works correctly (dbb12f4b)
  • Type: Allow much more string date formats to be valid union fallback member (5218a10a)
  • BSON: Serialize object type + nested documents (755b6d1f)
  • HTTP: Allow to read the request body multiple times (d020be88)
  • MySQL: MySQL expects the table name in DROP INDEX (fe5c54ba)
  • SQL: Correctly format multiple nested joins (e4c12dec)
  • SQLite: SQL schema parser ignores now invalid foreign keys (bb770dad)
  • Type: Merge two object literals overrides left properties (2ef28b9c)

Chore

  • Used newer postgres version in tests (156caa2d)
  • Ensure database token with default constructor params work (a34e9394)
  • Type Compiler: Added ts-ignore to all synthetic imports (ec55a42a)

Contributors

  • Marc J. Schmidt
  • René Fritz

How to update

npx update-by-scope @deepkit

v1.0.1-alpha.77

1 year ago

Features

  • TypeScript 4.8 support
  • SQL: Added LIKE support for all db adapters (613c3a33)
  • ORM: Added SELECT FOR UPDATE/SHARE support (2170c5ea)
  • Type Compiler: Support reflectionOptions to exclude d.ts files from being embedded (d46c35e5)
  • HTTP: Make action groups ordered (2b099dce)
  • Type Compiler: Target=es2022 now correctly loads TS libs (c8b92a2b)
  • Type: Allow using (self) function type reference (7191c585)
  • Framework: Expose log messages in TestingFacade (28de6879)
  • Create App: New package @deepkit/create-app to easily get a Deepkit project up and going via npm init @deepkit/app project-name (3088e829)
  • Type: Support key remapping in mapped types (031b0703)

Fixes

  • SQLite: Fix off-by-one in max number of active connections (d7890e1f)
  • Type: Make sure validation returns all errors on object literals (2bb6ef1a, 7e965bd9)
  • HTTP: Filter with forRoutes() (b139e70b)
  • Type Compiler: Converted more function calls to new signature (64e525ac)
  • Type Compiler: Correctly serialize dist path (bacd2339)
  • ORM: Optional reference fields (e229380f)
  • Test: Correct type of reference (d18196b3)
  • BSON: Make sure ValueWithBSONSerializer correctly serializes undefined/null (e7edfce3)
  • SQL: Allow batch updating multiple different changed fields (513a8180)
  • SQL: Make sure the database serializer is used for formatting (e5bf8733)
  • SQLite: Memory dbs can only have 1 connection (3ad96787)
  • RPC: Memory leak with registered client as peer (db9d3659)
  • Type: Keep optionality of property signatures intact when doing mapped types + distributive conditional types (1687a572)
  • Mongo: Scram response needs to extend from BaseResponse (c1d6c415)
  • HTTP: Add type to RouteParameterResolverContext (f74c1ec8)

Chore

  • Package.json: Add "types" in package.json "exports" (b04dae7f)
  • Remove turbo-net (752c1dbf)
  • Readme: Add links to community packages and examples to readme (37c39622)
  • Updated GUIs to angular v15 (5ddf8413)

Contributors

  • Tim van Dam
  • Marc J. Schmidt
  • Char2s
  • Pavel Voronin
  • fergusean
  • CristianPi

Update

To update your project to the newest Deepkit versions, you can use:

npx update-by-scope @deepkit

v1.0.1-alpha.75

1 year ago

Features

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]

Bugfixes

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]

Chore

9cc2e278 - chore(type): test to cover function parameter serialisation [Marc J. Schmidt] c0f5299f - chore(sqlite): make sure m2m joins work [Marc J. Schmidt]

v1.0.1-alpha.74

1 year ago

Features

c2400a65 - feature(type): support static reflection [Marc J. Schmidt]

Bug fixes

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]

Chore

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]

v1.0.1-alpha.72

1 year ago

Version alpha-72 comes with a lot of new features and bugfixes.

Features

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();
  • Type compiler no longer uses TypeScript's TypeChecker and added a loader API that is the foundation for per-file compilation support for build systems like esbuild/SWC.

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]

Bufixes / Chore

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