Skip to content

Commit 50f4100

Browse files
committed
Changing signature to not return the Contract result but the actual results
1 parent 9b4cd3d commit 50f4100

File tree

5 files changed

+13
-34
lines changed

5 files changed

+13
-34
lines changed

Source/Clients/Api/Projections/SaveProjection.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public record SaveProjection(string EventStore, string Namespace, string Declara
1919
/// Handles the save projection request.
2020
/// </summary>
2121
/// <param name="projections">The <see cref="IProjections"/> service.</param>
22-
/// <returns>Result of saving the projection.</returns>
23-
internal async Task<SaveProjectionResult> Handle(IProjections projections)
22+
/// <returns>Collection of syntax errors, if any.</returns>
23+
internal async Task<IEnumerable<ProjectionDeclarationSyntaxError>> Handle(IProjections projections)
2424
{
2525
var request = new SaveProjectionRequest
2626
{
@@ -36,6 +36,7 @@ internal async Task<SaveProjectionResult> Handle(IProjections projections)
3636
: null
3737
};
3838

39-
return await projections.Save(request);
39+
var result = await projections.Save(request);
40+
return result.Errors.ToApi();
4041
}
4142
}

Source/Workbench/Web/Api/Projections/SaveProjection.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @generated by Cratis. Source: Cratis.Chronicle.Api.Projections.SaveProjection. Time: 2026-01-31T09:21:29.7381330Z. Hash: E4F3AE9860C9117C0696CD8B2CF6AB787A94D9E81C8E52975DC5E229A75982CC
1+
// @generated by Cratis. Source: Cratis.Chronicle.Api.Projections.SaveProjection. Time: 2026-02-04T08:41:26.8151290Z. Hash: D9D17D53F2374E721623B8B80F72F13631F4EBFEF4A1BC9907298ED6E96F5763
22
/*---------------------------------------------------------------------------------------------
33
* **DO NOT EDIT** - This file is an automatically generated file.
44
*--------------------------------------------------------------------------------------------*/
@@ -10,18 +10,18 @@ import { Command, CommandValidator } from '@cratis/arc/commands';
1010
import { useCommand, SetCommandValues, ClearCommandValues } from '@cratis/arc.react/commands';
1111
import { PropertyDescriptor } from '@cratis/arc/reflection';
1212
import { DraftReadModel } from './DraftReadModel';
13-
import { SaveProjectionResult } from './SaveProjectionResult';
13+
import { ProjectionDeclarationSyntaxError } from './ProjectionDeclarationSyntaxError';
1414

1515
/**
1616
* Represents a request to save a projection from its projection declaration language representation.
1717
*/
1818
export interface ISaveProjection {
19-
19+
2020
/**
2121
* The projection declaration language representation of the projection.
2222
*/
2323
declaration?: string;
24-
24+
2525
/**
2626
* Optional draft read model definition to save along with the projection.
2727
*/
@@ -31,7 +31,7 @@ export interface ISaveProjection {
3131
* The event store the projection targets.
3232
*/
3333
eventStore?: string;
34-
34+
3535
/**
3636
* The namespace the projection targets.
3737
*/
@@ -47,7 +47,7 @@ export class SaveProjectionValidator extends CommandValidator<ISaveProjection> {
4747
/**
4848
* Represents a request to save a projection from its projection declaration language representation.
4949
*/
50-
export class SaveProjection extends Command<ISaveProjection, SaveProjectionResult> implements ISaveProjection {
50+
export class SaveProjection extends Command<ISaveProjection, ProjectionDeclarationSyntaxError> implements ISaveProjection {
5151
readonly route: string = '/api/projections/save-projection';
5252
readonly validation: CommandValidator = new SaveProjectionValidator();
5353
readonly propertyDescriptors: PropertyDescriptor[] = [
@@ -63,7 +63,7 @@ export class SaveProjection extends Command<ISaveProjection, SaveProjectionResul
6363
private _namespace!: string;
6464

6565
constructor() {
66-
super(SaveProjectionResult, false);
66+
super(ProjectionDeclarationSyntaxError, true);
6767
}
6868

6969
get requestParameters(): string[] {

Source/Workbench/Web/Api/Projections/SaveProjectionResult.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

Source/Workbench/Web/Api/Projections/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ export * from './ProjectionDeclarationSyntaxError';
1010
export * from './ProjectionPreview';
1111
export * from './ProjectionWithDeclaration';
1212
export * from './SaveProjection';
13-
export * from './SaveProjectionResult';

Source/Workbench/Web/Features/EventStore/General/Projections/Projections.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ export const Projections = () => {
248248
saveProjection.draftReadModel = draftReadModel;
249249
}
250250
const result = await saveProjection.execute();
251-
const errors = result.response?.errors ?? [];
252-
if (result.isSuccess) {
251+
const errors = result.response ?? [];
252+
if (result.isSuccess && errors.length === 0) {
253253
await refreshProjections({ eventStore: params.eventStore! });
254254
if (draftReadModel) {
255255
refreshReadModels({ eventStore: params.eventStore! }); // Only refresh read models if we created a new one

0 commit comments

Comments
 (0)