Conversation
Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/4c08bd3c-9d18-463d-8c8c-4c5fec8fcbf5 Co-authored-by: einari <134365+einari@users.noreply.github.com>
|
@copilot Great. Let's use the native TypeScript reflection capability to get the members and their types and translate that into the schema. Create a introspection tool that both the EventType and a new decorator @ReadModel can then use to populate the necessary metadata that can then be used by the EventType registration and ReadModel registration. |
Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/10b983ed-1c87-432d-a182-6cecf0e571f7 Co-authored-by: einari <134365+einari@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/10b983ed-1c87-432d-a182-6cecf0e571f7 Co-authored-by: einari <134365+einari@users.noreply.github.com>
Implemented in a5cb13c. I introduced a shared |
|
@copilot We only want @readModel not @ReadModel - only one case |
Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/d0d8735e-abf6-4811-8ee7-5fa8e1764e30 Co-authored-by: einari <134365+einari@users.noreply.github.com>
|
@copilot we don't want to have to rely on the @jsonSchemaProperty decorators, with the latest TypeScript and its reflect support, we should be able to get this through the @readModel and @eventtype decorators. Also, look closer at the C# client implementation on how projections are implemented - we're not even remotely close in this. There is no @modelBoundProjection attribute for instance, but we have a bunch of other attributes. I'm expecting a folder called Also, the TestApp should have samples of all of this. |
Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/d34b2733-db80-4dfd-baf3-a9179b84bf56 Co-authored-by: einari <134365+einari@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/d34b2733-db80-4dfd-baf3-a9179b84bf56 Co-authored-by: einari <134365+einari@users.noreply.github.com>
Implemented in 8578715 (with 06c955d): projection APIs are now split into Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot But you haven't implemented anything remotely close to the declarative and the model-bound projection APIs and decorators as expected. You have to implement the full support that we have in C# for these: The C# code is here: For the declarative model or anything that needs to describe a property for type safe conversion to a PropertyPath: |
Implemented in commits Declarative Projections (
Model-Bound Projections (
TestApp updated with a full declarative projection sample implementing |
Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/a357eb10-359d-41f3-8d2f-3c62c164c7d7 Co-authored-by: einari <134365+einari@users.noreply.github.com>
Pushed in Declarative (
Model-Bound ( TestApp updated with full working samples of both styles. |
|
@copilot Lets move the constraints into the events folder, like we have done in the .NET client. Also, it needs to be implemented, look at how we've done it in C# (https://github.com/Cratis/Chronicle/blob/main/Source/Clients/DotNET/Events/Constraints/IConstraint.cs). The Sample app needs to also split its artifacts out into multiple files and there can't be two projections for the same read model or two read models with the same type name. |
…lit TestApp into files Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/69522283-d84e-48ea-950a-7908a80fbfda Co-authored-by: einari <134365+einari@users.noreply.github.com>
Done in Constraints moved to
TestApp split into separate files:
|
|
@copilot We now have 2 folders for constraints, one in the root and one in events, we only want the one in events.
|
…s and implementations Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/e509efef-82e9-4593-a21c-41d503004484 Co-authored-by: einari <134365+einari@users.noreply.github.com>
…y constructors Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/e509efef-82e9-4593-a21c-41d503004484 Co-authored-by: einari <134365+einari@users.noreply.github.com>
Done in
|
|
@copilot Lets keep one type per file (interfaces, classes, abstract classes, enums...) And drop suffixes like "Impl" to things. Fix everything. |
Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/e60ed382-ede1-4b77-9f2e-2889116ef533 Co-authored-by: einari <134365+einari@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Cratis/Chronicle.TypeScript/sessions/e60ed382-ede1-4b77-9f2e-2889116ef533 Co-authored-by: einari <134365+einari@users.noreply.github.com>
Done in
Also dropped the |
|
@copilot resolve the merge conflicts in this pull request. We've switched to YARN, don't need the package-lock.json file at all. Pull main into the this and you're golden |
Co-authored-by: einari <134365+einari@users.noreply.github.com>
Done in |
This PR expands client artifact discovery beyond event types/reactors/reducers so reducers can surface read models and schema metadata, and so constraints plus both projection styles are discoverable through decorators. It also introduces reflection-based JSON schema generation hooks for decorated types and a complete TypeScript implementation of the Chronicle projection engine API for both declarative and model-bound projections.
Added — Artifact decorators and metadata
@readModel@constraint@projection(declarative)@modelBound(model-bound)Changed — Artifact discovery and provider contract
DecoratorTypewithReadModel,Constraint,Projection, andModelBoundProjection.IClientArtifactsProvider/DefaultClientArtifactsProviderwith:readModelsconstraintsprojectionsmodelBoundProjectionsTypeDiscoverer-based discovery flow.Added — Shared reflection introspection for schema metadata
TypeIntrospectoras a shared introspection tool.@eventTypeand@readModelto populate metadata from the same introspection path.Added — JSON Schema support via reflection metadata
Schemasmodule with:JsonSchematypeJsonSchemaGeneratorgetEventTypeJsonSchemaFor()to generate schema for event types (with a deterministic empty schema for undecorated types).reflect-metadata— no additional property decorators required.Changed — Reducer/read-model linkage
@reducer(...)metadata to optionally carry a read model constructor.@reducer, it is also registered as a discoverable read model artifact.Added — Full declarative projection builder API (
Projections/declarative/)IProjectionFor<TReadModel>— user-facing contract: implementdefine(builder)on any@projectionclass.IProjectionBuilderFor<TReadModel>— top-level builder:fromEventSequence,containerName,notRewindable,passive.IProjectionBuilder<TReadModel, TBuilder>— core fluent builder:from<TEvent>,join<TEvent>,fromEvery,removedWith<TEvent>,removedWithJoin<TEvent>,children,nested,autoMap,noAutoMap,withInitialValues.IReadModelPropertiesBuilder— shared property mapping:set,add,subtract,increment,decrement,count,addChild,setThisValue,usingKey,usingParentKey,usingCompositeKey,usingConstantKey, and more.IFromBuilder,IJoinBuilder,IFromEveryBuilder,IChildrenBuilder,INestedBuilder,IRemovedWithBuilder,IRemovedWithJoinBuilder,ISetBuilder,IAddBuilder,ISubtractBuilder,IAllSetBuilder,ICompositeKeyBuilder,IAddChildBuilder.PropertyAccessor<T>from@cratis/fundamentalsfor type-safe property path expressions.Added — Full model-bound projection decorator API (
Projections/modelBound/)ModelBoundnamespace:@fromEvent(eventType, options?)— class decorator (supportskey,parentKey,constantKey)@setFrom(eventType, eventPropertyName?),@setFromContext(eventType, contextPropertyName?)— property decorators@join(eventType, on?, eventPropertyName?)— property decorator@addFrom(eventType, eventPropertyName?),@subtractFrom(eventType, eventPropertyName?)— property decorators@increment(eventType, constantKey?),@decrement(eventType, constantKey?),@count(eventType, constantKey?)— property decorators@childrenFrom(eventType, key?, identifiedBy?, parentKey?)— property decorator@nested— property decorator@clearWith(eventType),@removedWith(eventType, key?, parentKey?),@removedWithJoin(eventType, key?)— class or property decorators@notRewindable— class decorator@setValue(eventType, value),@fromEvery(property?, contextProperty?)— property decoratorsreflect-metadatawith corresponding getter helpers.Changed — Constraints moved exclusively to
Events/Constraints/(matching .NET client layout)Source/Constraints/folder removed; constraints live solely underSource/Events/Constraints/.IConstraint— implementdefine(builder: IConstraintBuilder)on any@constraintclass.IConstraintBuilder—perEventSourceType(),perEventStreamType(),perEventStreamId(),unique(callback),uniqueFor(eventType, message?, name?).IUniqueConstraintBuilder—withName(),on<TEvent>(...properties),ignoreCasing(),removedWith(eventType),withMessage(),withMessageFrom(provider).Added — Per-module Kernel registration types
IEventTypes+EventTypes(Source/Events/) — discovers and registers event types with the Kernel via gRPC.IConstraints+Constraints(Source/Events/Constraints/) — discovers and registers constraints via gRPC with full builder-to-contract translation.IProjections+Projections(Source/Projections/) — discovers declarative and model-bound projections (full serialization deferred).IReactors+Reactors(Source/Reactors/) — discovers reactors (streaming gRPC registration deferred).IReducers+Reducers(Source/Reducers/) — discovers reducers (streaming gRPC registration deferred).IEventStoreexposeseventTypes,constraints,projections,reactors, andreducersproperties.EventStorecreates all registrars and callsregisterArtifacts()on initial connect.Changed — Public API surface
ReadModels,Constraints,Projections, andSchemasmodules from the root barrel.Changed — TestApp split into separate artifact files
Events.ts— all@eventTypeclassesReadModels.ts— distinct@readModelclasses per projection styleProjections.ts— declarative@projectionclass implementingIProjectionFor<EmployeeReadModel>ModelBoundProjections.ts— model-bound@modelBoundclasses with distinct read model shapesConstraints.ts—UniqueEmployeeNameConstraintimplementingIConstraintwith a real builder definitionReactors.ts— event reactor classindex.ts— imports all artifact files and runs the main flow